Clang Flag: -Wdeprecated-this-capture / -Wno-deprecated-this-capture

From emmtrix Wiki
Jump to navigation Jump to search
The Clang compiler flags -Wdeprecated-this-capture and -Wno-deprecated-this-capture are used to manage warnings related to the deprecated use of the this pointer in lambda captures. By default, the Clang compiler emits a warning when the this pointer is implicitly captured in a lambda with a capture default of =, indicating a potentially unsafe or unintended use of this within the lambda's body. This behavior can be controlled using these flags.

The -Wno-deprecated-this-capture flag is active by default, which means the compiler does not emit a warning when the this pointer is captured implicitly. This default behavior ensures backward compatibility with existing codebases that may rely on this pattern, but may overlook potential issues related to the lifetime of captured this pointers. Developers can explicitly activate the warning by using the -Wdeprecated-this-capture flag, though it does not apply in this context as the section for "Default Inactive" does not list any elements.

In summary, the use of -Wno-deprecated-this-capture suppresses the warning associated with the deprecated practice of implicitly capturing the this pointer in lambdas, aligning with the compiler's default setting.

 
AI Generated

Supergroups

Subroups

Warnings/Remarks

Default Active (Deactivate with -Wno-deprecated-this-capture)

warn_deprecated_this_capture warning: implicit capture of 'this' with a capture default of '=' is deprecated

Default Inactive (Activate with -Wdeprecated-this-capture)

None