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

From emmtrix Wiki
Jump to navigation Jump to search
The Clang compiler flags -Wc++17-compat-pedantic and -Wno-c++17-compat-pedantic are used to control the emission of warnings related to compatibility with the C++17 standard in a more pedantic manner. These flags are part of a wider set of diagnostic tools that help developers ensure that their code complies with specific versions of the C++ standard, by flagging constructs that may not be compatible or that deviate from the stricter interpretation of the standard.

-Wc++17-compat-pedantic is inactive by default and can be enabled to diagnose compatibility issues that could hinder a project's migration to C++17 or later standards. When activated, it covers a range of warnings that alert developers about code patterns or features that are either deprecated in C++17 or have changed behavior in the updated standard. Typical issues highlighted include but are not limited to changes in template argument deduction, constexpr restrictions, and modified rules for auto type deduction.

Conversely, -Wno-c++17-compat-pedantic serves to suppress these pedantic warnings about C++17 compatibility. This suppression is particularly useful when maintaining backward compatibility or when working with legacy codebases that rely on behaviors now considered deprecated or non-standard in C++17. By default, this flag is active to avoid overwhelming projects with warnings about code that was previously considered standard-compliant but is now flagged under the stricter C++17 compatibility checks.

Together, these flags offer developers granular control over how strictly they wish to enforce C++17 compatibility, allowing them to incrementally address potential issues or to suppress them where maintaining existing behavior is necessary. This flexibility supports a variety of development and migration strategies, from modernizing old codebases to ensuring new projects are future-proofed against evolving C++ standards.

 
AI Generated

Supergroups

Subroups

Warnings/Remarks

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

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-pedantic)

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

warn_cxx17_compat_designated_init warning: designated initializers are incompatible with C++ standards before C++20
warn_cxx17_compat_pointer_to_const_ref_member_on_rvalue warning: invoking a pointer to a 'const &' member function on an rvalue is incompatible with C++ standards before C++20
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: 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: 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: 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: 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: 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: 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: 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: warning: use of this statement in a constexpr
function
constructor
is incompatible with C++ standards before C++23

warn_cxx20_compat_constexpr_var
warning: 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: 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: 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: 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: warning:
delimited
named
escape sequences are incompatible with C++ standards before C++23