Clang Flag: -Wc++20-extensions / -Wno-c++20-extensions

From emmtrix Wiki
Jump to navigation Jump to search
The Clang compiler flags -Wc++20-extensions and -Wno-c++20-extensions are utilized to manage warnings concerning features that are considered extensions to the C++20 standard. These flags are instrumental for developers aiming to ensure compatibility with the C++20 standard or to avoid relying on extensions that might not be supported by all compilers or might affect portability.

The flag -Wc++20-extensions enables warnings for code that uses features considered to be extensions to C++20. This flag is not enabled by default but can be activated to help developers identify and possibly avoid or refactor code that relies on these non-standard extensions. Such a proactive approach aids in maintaining code that is conformant with the C++20 standard, thereby enhancing its compatibility and portability across different compilers and platforms.

Conversely, the flag -Wno-c++20-extensions suppresses warnings about C++20 extensions. This flag is useful when working with codebases that intentionally use C++20 extensions for various reasons, such as leveraging compiler-specific optimizations or features that enhance the functionality beyond the standard. By suppressing these warnings, developers can keep the compilation output clean and focused on more pertinent issues.

These flags underscore the balance between adhering to the C++20 standard and the pragmatic use of compiler extensions to meet project-specific needs. Developers are encouraged to use these flags judiciously to maintain high standards of code quality and compatibility while leveraging the full spectrum of features offered by the Clang compiler.

 
AI Generated

Supergroups

Subroups

Warnings/Remarks

Default Active (Deactivate with -Wno-c++20-extensions)

ext_adl_only_template_id warning: use of function template name with no prior declaration in function call with explicit template arguments is a C++20 extension
ext_bitfield_member_init warning: default member initializer for bit-field is a C++20 extension
ext_capture_binding warning: captured structured bindings are a C++20 extension
ext_constexpr_body_invalid_stmt_cxx20
warning: use of this statement in a constexpr
function
constructor
is a C++20 extension

ext_constexpr_ctor_missing_init warning: constexpr constructor that does not initialize all members is a C++20 extension
ext_constexpr_function_try_block_cxx20
warning: function try block in constexpr
function
constructor
is a C++20 extension

ext_constexpr_local_var_no_init
warning: uninitialized variable in a constexpr
function
constructor
is a C++20 extension

ext_constexpr_union_ctor_no_init warning: constexpr union constructor that does not initialize any member is a C++20 extension
ext_decomp_decl_spec
warning: decomposition declaration declared
'B'
with 'B' specifiers
is a C++20 extension

ext_defaulted_comparison warning: defaulted comparison operators are a C++20 extension
ext_equals_this_lambda_capture_cxx20 warning: explicit capture of 'this' with a capture default of '=' is a C++20 extension
ext_explicit_bool warning: explicit(bool) is a C++20 extension
ext_for_range_init_stmt warning: range-based for loop initialization statements are a C++20 extension
ext_implicit_typename warning: missing 'typename' prior to dependent type name AB; implicit 'typename' is a C++20 extension
ext_init_capture_pack warning: initialized lambda pack captures are a C++20 extension
ext_inline_nested_namespace_definition warning: inline nested namespace definition is a C++20 extension
ext_lambda_template_parameter_list warning: explicit template parameter list for lambdas is a C++20 extension
ext_using_decl_scoped_enumerator warning: using declaration naming a scoped enumerator is a C++20 extension
ext_using_enum_declaration warning: using enum declaration is a C++20 extension

Default Inactive (Activate with -Wc++20-extensions)

ext_pointer_to_const_ref_member_on_rvalue warning: invoking a pointer to a 'const &' member function on an rvalue is a C++20 extension
warn_cxx17_compat_aggregate_init_paren_list warning: aggregate initialization of type A from a parenthesized list of values is a C++20 extension
ext_cxx_designated_init warning: designated initializers are a C++20 extension
ext_cxx20_attr warning: use of the A attribute is a C++20 extension