Clang Flag: -Wc++17-compat / -Wno-c++17-compat

From emmtrix Wiki
Jump to navigation Jump to search
The Clang compiler flags -Wc++17-compat and -Wno-c++17-compat are used to control warnings related to compatibility with the C++17 standard.

The -Wc++17-compat flag is designed to warn developers about code patterns or constructs in their C++ code that may be incompatible with the C++17 standard or that may behave differently in C++17. This flag is useful for projects that aim to maintain compatibility across multiple C++ standards or for those preparing to transition to C++17. Upon activation, it generates warnings for code that, while valid in previous or later versions of the C++ standard, might not be compatible with C++17, focusing on features and behaviors introduced or changed in C++20 and beyond.

Conversely, the -Wno-c++17-compat flag suppresses these compatibility warnings, making it useful when developers are aware of compatibility issues but choose to ignore them for the time being, perhaps due to project constraints or the deliberate targeting of features available in newer C++ standards.

In summary, these flags assist developers in navigating the complexities associated with maintaining or achieving compatibility with the C++17 standard, providing guidance on changes that may affect their code's behavior when compiled with C++17.

 
AI Generated

Supergroups

Subroups

Warnings/Remarks

Default Active (Deactivate with -Wno-c++17-compat)

warn_deprecated_register warning: 'register' storage class specifier is deprecated and incompatible with C++17
warn_increment_bool warning: incrementing expression of type bool is deprecated and incompatible with C++17
warn_cxx17_compat_exception_spec_in_signature warning: mangled name of A will change in C++17 due to non-throwing exception specification in function signature

Default Inactive (Activate with -Wc++17-compat)

warn_cxx17_compat_adl_only_template_id warning: use of function template name with no prior function template declaration in function call with explicit template arguments is incompatible with C++ standards before C++20
warn_cxx17_compat_bitfield_member_init warning: default member initializer for bit-field is incompatible with C++ standards before C++20
warn_cxx17_compat_capture_binding warning: captured structured bindings are incompatible with C++ standards before C++20
warn_cxx17_compat_constexpr_body_invalid_stmt
warning: use of this statement in a constexpr
function
constructor
is incompatible with C++ standards before C++20

warn_cxx17_compat_constexpr_ctor_missing_init warning: constexpr constructor that does not initialize all members is incompatible with C++ standards before C++20
warn_cxx17_compat_constexpr_function_try_block
warning: function try block in constexpr
function
constructor
is incompatible with C++ standards before C++20

warn_cxx17_compat_constexpr_local_var_no_init
warning: uninitialized variable in a constexpr
function
constructor
is incompatible with C++ standards before C++20

warn_cxx17_compat_constexpr_union_ctor_no_init warning: constexpr union constructor that does not initialize any member is incompatible with C++ standards before C++20
warn_cxx17_compat_constexpr_virtual warning: virtual constexpr functions are incompatible with C++ standards before C++20
warn_cxx17_compat_decomp_decl_spec
warning: decomposition declaration declared
'B'
with 'B' specifiers
is incompatible with C++ standards before C++20

warn_cxx17_compat_defaulted_comparison warning: defaulted comparison operators are incompatible with C++ standards before C++20
warn_cxx17_compat_defaulted_method_type_mismatch
warning: explicitly defaulting this
default constructor
copy constructor
move constructor
copy assignment operator
move assignment operator
destructor
with a type different from the implicit type is incompatible with C++ standards before C++20

warn_cxx17_compat_equals_this_lambda_capture warning: explicit capture of 'this' with a capture default of '=' is incompatible with C++ standards before C++20
warn_cxx17_compat_explicit_bool warning: explicit(bool) is incompatible with C++ standards before C++20
warn_cxx17_compat_for_range_init_stmt warning: range-based for loop initialization statements are incompatible with C++ standards before C++20
warn_cxx17_compat_init_capture_pack warning: initialized lambda capture packs are incompatible with C++ standards before C++20
warn_cxx17_compat_inline_nested_namespace_definition warning: inline nested namespace definition is incompatible with C++ standards before C++20
warn_cxx17_compat_lambda_def_ctor_assign
warning:
default construction
assignment
of lambda is incompatible with C++ standards before C++20

warn_cxx17_compat_lambda_template_parameter_list warning: explicit template parameter list for lambdas is incompatible with C++ standards before C++20
warn_cxx17_compat_missing_varargs_arg warning: passing no argument for the '...' parameter of a variadic macro is incompatible with C++ standards before C++20
warn_cxx17_compat_spaceship warning: '<=>' operator is incompatible with C++ standards before C++20
warn_cxx17_compat_template_nontype_parm_type warning: non-type template parameter of type A is incompatible with C++ standards before C++20
warn_cxx17_compat_unicode_type warning: 'char8_t' type specifier is incompatible with C++ standards before C++20
warn_cxx17_compat_using_decl_class_member_enumerator warning: member using declaration naming a non-member enumerator is incompatible with C++ standards before C++20
warn_cxx17_compat_using_decl_non_member_enumerator warning: member using declaration naming non-class 'A' enumerator is incompatible with C++ standards before C++20
warn_cxx17_compat_using_decl_scoped_enumerator warning: using declaration naming a scoped enumerator is incompatible with C++ standards before C++20
warn_cxx17_compat_using_enum_declaration warning: using enum declaration is incompatible with C++ standards before C++20
ext_subscript_overload
warning: overloaded A with
no
a defaulted
more than one
parameter is a C++23 extension

warn_cxx20_alias_in_init_statement warning: alias declaration in this context is incompatible with C++ standards before C++23
warn_cxx20_compat_auto_expr warning: 'auto' as a functional-style cast is incompatible with C++ standards before C++23
warn_cxx20_compat_consteval_if warning: consteval if is incompatible with C++ standards before C++23
warn_cxx20_compat_constexpr_body_invalid_stmt
warning: use of this statement in a constexpr
function
constructor
is incompatible with C++ standards before C++23

warn_cxx20_compat_constexpr_var
warning: definition of a
static variable
thread_local variable
variable of non-literal type
in a constexpr
function
constructor
is incompatible with C++ standards before C++23

warn_cxx20_compat_decl_attrs_on_lambda
warning:
an attribute specifier sequence
B
in this position is incompatible with C++ standards before C++23

warn_cxx20_compat_label_end_of_compound_statement warning: label at end of compound statement is incompatible with C++ standards before C++23
warn_cxx20_compat_operator_overload_static warning: declaring overloaded A as 'static' is incompatible with C++ standards before C++23
warn_cxx20_compat_size_t_suffix warning: 'size_t' suffix for literals is incompatible with C++ standards before C++23
warn_cxx20_compat_static_lambda warning: static lambdas are incompatible with C++ standards before C++23
warn_cxx23_compat_defaulted_comparison_constexpr_mismatch
warning: defaulted definition of
equality
three-way
equality
relational
comparison operator
three-way comparison operator
that is declared
constexpr
consteval
but
 
for which the corresponding implicit 'operator=='
invokes a non-constexpr comparison function is incompatible with C++ standards before C++23

warn_cxx23_compat_pp_directive
warning: use of a '#
elifdef
elifndef
' directive is incompatible with C++ standards before C++23

warn_cxx23_compat_warning_directive warning: #warning is incompatible with C++ standards before C++23
warn_cxx23_delimited_escape_sequence
warning:
delimited
named
escape sequences are incompatible with C++ standards before C++23