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

From emmtrix Wiki
Jump to navigation Jump to search
The Clang compiler flags -Wc++98-compat and -Wno-c++98-compat are used to manage warnings related to C++98 compatibility. Specifically, -Wc++98-compat activates warnings that flag constructs in the code that are incompatible with the C++98 standards. This is particularly useful for developers aiming to maintain compatibility with older C++ standards or for projects that must be portable across environments where only C++98 standard is supported.

Given that there are no default active elements for -Wno-c++98-compat as indicated by the absence of related elements under "Default Active (Deactivate with -Wno-c++98-compat)", this part of the flag does not require further elaboration.

On the other hand, the -Wc++98-compat flag is default inactive, which means it requires explicit activation to enforce C++98 compatibility checks. When enabled, it examines a wide array of features introduced in C++ standards post-C++98, such as alias declarations, alignas specifier, attributes, auto type specifier, constexpr, and many more, flagging those that are not compatible with the C++98 standard. By invoking this flag, developers can identify and refactor such features to adhere to C++98 standards, ensuring broader compatibility of their codebase.

Utilizing -Wc++98-compat is essential for projects where compliance with C++98 is crucial, either due to legacy system requirements, cross-platform portability concerns, or specific project guidelines that dictate adherence to older standards. This flag supplements the thorough review and manual code adjustments by programmatically highlighting incompatibilities, thus streamlining the process of ensuring C++98 compatibility.

 
AI Generated

Supergroups

Subroups

Warnings/Remarks

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

None

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

warn_cxx98_compat_alias_declaration warning: alias declarations are incompatible with C++98
warn_cxx98_compat_alignas warning: 'alignas' is incompatible with C++98
warn_cxx98_compat_alignof warning: alignof expressions are incompatible with C++98
warn_cxx98_compat_attribute warning: [[]] attributes are incompatible with C++ standards before C++11
warn_cxx98_compat_auto_type_specifier warning: 'auto' type specifier is incompatible with C++98
warn_cxx98_compat_constexpr warning: 'constexpr' specifier is incompatible with C++98
warn_cxx98_compat_ctor_list_init warning: constructor call from initializer list is incompatible with C++98
warn_cxx98_compat_decltype warning: 'decltype' type specifier is incompatible with C++98
warn_cxx98_compat_defaulted_deleted_function
warning:
defaulted
deleted
function definitions are incompatible with C++98

warn_cxx98_compat_delegating_ctor warning: delegating constructors are incompatible with C++98
warn_cxx98_compat_empty_scalar_initializer warning: scalar initialized from empty initializer list is incompatible with C++98
warn_cxx98_compat_empty_sizeless_initializer warning: initializing A from an empty initializer list is incompatible with C++98
warn_cxx98_compat_enum_fixed_underlying_type warning: enumeration types with a fixed underlying type are incompatible with C++98
warn_cxx98_compat_enum_friend warning: befriending enumeration type A is incompatible with C++98
warn_cxx98_compat_enum_nested_name_spec warning: enumeration type in nested name specifier is incompatible with C++98
warn_cxx98_compat_explicit_conversion_functions warning: explicit conversion functions are incompatible with C++98
warn_cxx98_compat_for_range warning: range-based for loop is incompatible with C++98
warn_cxx98_compat_friend_is_member warning: friend declaration naming a member of the declaring class is incompatible with C++98
warn_cxx98_compat_generalized_initializer_lists warning: generalized initializer lists are incompatible with C++98
warn_cxx98_compat_goto_into_protected_scope warning: jump from this goto statement to its label is incompatible with C++98
warn_cxx98_compat_indirect_goto_in_protected_scope
warning: jump from this
indirect
asm
goto statement to one of its possible targets is incompatible with C++98

warn_cxx98_compat_initializer_list_init warning: initialization of initializer_list object is incompatible with C++98
warn_cxx98_compat_inline_namespace warning: inline namespaces are incompatible with C++98
warn_cxx98_compat_lambda warning: lambda expressions are incompatible with C++98
warn_cxx98_compat_less_colon_colon warning: '<::' is treated as digraph '<:' (aka '[') followed by ':' in C++98
warn_cxx98_compat_literal_operator warning: literal operators are incompatible with C++98
warn_cxx98_compat_literal_ucn_control_character warning: universal character name referring to a control character is incompatible with C++98
warn_cxx98_compat_literal_ucn_escape_basic_scs warning: specifying character 'A' with a universal character name is incompatible with C++98
warn_cxx98_compat_noexcept_decl warning: noexcept specifications are incompatible with C++98
warn_cxx98_compat_noexcept_expr warning: noexcept expressions are incompatible with C++98
warn_cxx98_compat_non_static_member_use warning: use of non-static data member A in an unevaluated context is incompatible with C++98
warn_cxx98_compat_nonclass_type_friend warning: non-class friend type A is incompatible with C++98
warn_cxx98_compat_nonstatic_member_init warning: default member initializer for non-static data members is incompatible with C++98
warn_cxx98_compat_nontrivial_union_or_anon_struct_member
warning:
anonymous struct
union
member B with a non-trivial
default constructor
copy constructor
move constructor
copy assignment operator
move assignment operator
destructor
is incompatible with C++98

warn_cxx98_compat_nullptr warning: 'nullptr' is incompatible with C++98
warn_cxx98_compat_override_control_keyword warning: 'A' keyword is incompatible with C++98
warn_cxx98_compat_pass_non_pod_arg_to_vararg
warning: passing object of trivial but non-POD type A through variadic
function
block
method
constructor
is incompatible with C++98

warn_cxx98_compat_raw_string_literal warning: raw string literals are incompatible with C++98
warn_cxx98_compat_ref_qualifier warning: reference qualifiers on functions are incompatible with C++98
warn_cxx98_compat_reference_list_init warning: reference initialized from initializer list is incompatible with C++98
warn_cxx98_compat_rvalue_reference warning: rvalue references are incompatible with C++98
warn_cxx98_compat_scoped_enum warning: scoped enumerations are incompatible with C++98
warn_cxx98_compat_sfinae_access_control warning: substitution failure due to access control is incompatible with C++98
warn_cxx98_compat_static_assert warning: 'static_assert' declarations are incompatible with C++98
warn_cxx98_compat_static_data_member_in_union warning: static data member A in union is incompatible with C++98
warn_cxx98_compat_switch_into_protected_scope warning: jump from switch statement to this case label is incompatible with C++98
warn_cxx98_compat_template_arg_extra_parens warning: redundant parentheses surrounding address non-type template argument are incompatible with C++98
warn_cxx98_compat_template_arg_null warning: use of null pointer as non-type template argument is incompatible with C++98
warn_cxx98_compat_template_arg_object_internal
warning: non-type template argument referring to
function
object
B with internal linkage is incompatible with C++98

warn_cxx98_compat_template_outside_of_template warning: use of 'template' keyword outside of a template is incompatible with C++98
warn_cxx98_compat_template_parameter_default_in_function_template warning: default template arguments for a function template are incompatible with C++98
warn_cxx98_compat_trailing_return_type warning: trailing return types are incompatible with C++98
warn_cxx98_compat_two_right_angle_brackets warning: consecutive right angle brackets are incompatible with C++98 (use '> >')
warn_cxx98_compat_typename_outside_of_template warning: use of 'typename' outside of a template is incompatible with C++98
warn_cxx98_compat_unelaborated_friend_type
warning: befriending B without '
struct
interface
union
class
enum
' keyword is incompatible with C++98

warn_cxx98_compat_unicode_literal warning: unicode literals are incompatible with C++98
warn_cxx98_compat_unicode_type warning: 'A' type specifier is incompatible with C++98
warn_cxx98_compat_using_decl_constructor warning: inheriting constructors are incompatible with C++98
warn_cxx98_compat_variadic_templates warning: variadic templates are incompatible with C++98
warn_cxx98_compat_template_arg_local_type warning: local type A as template argument is incompatible with C++98
warn_cxx98_compat_template_arg_unnamed_type warning: unnamed type as template argument is incompatible with C++98
warn_cxx11_compat_constexpr_body_invalid_stmt
warning: use of this statement in a constexpr
function
constructor
is incompatible with C++ standards before C++14

warn_cxx11_compat_constexpr_body_multiple_return warning: multiple return statements in constexpr function is incompatible with C++ standards before C++14
warn_cxx11_compat_constexpr_body_no_return warning: constexpr function with no return statements is incompatible with C++ standards before C++14
warn_cxx11_compat_constexpr_local_var
warning: variable declaration in a constexpr
function
constructor
is incompatible with C++ standards before C++14

warn_cxx11_compat_constexpr_type_definition
warning: type definition in a constexpr
function
constructor
is incompatible with C++ standards before C++14

warn_cxx11_compat_decltype_auto_type_specifier warning: 'decltype(auto)' type specifier is incompatible with C++ standards before C++14
warn_cxx11_compat_deduced_return_type warning: return type deduction is incompatible with C++ standards before C++14
warn_cxx11_compat_digit_separator warning: digit separators are incompatible with C++ standards before C++14
warn_cxx11_compat_generic_lambda warning: generic lambdas are incompatible with C++11
warn_cxx11_compat_init_capture warning: initialized lambda captures are incompatible with C++ standards before C++14
warn_cxx11_compat_variable_template warning: variable templates are incompatible with C++ standards before C++14
warn_cxx14_compat_class_template_argument_deduction
warning: class template argument deduction is incompatible with C++ standards before C++17
 
; for compatibility, use explicit type name B

warn_cxx14_compat_constexpr_if warning: constexpr if is incompatible with C++ standards before C++17
warn_cxx14_compat_constexpr_on_lambda warning: constexpr on lambda expressions is incompatible with C++ standards before C++17
warn_cxx14_compat_decomp_decl warning: decomposition declarations are incompatible with C++ standards before C++17
warn_cxx14_compat_fold_expression warning: pack fold expression is incompatible with C++ standards before C++17
warn_cxx14_compat_init_statement
warning:
if
switch
initialization statements are incompatible with C++ standards before C++17

warn_cxx14_compat_inline_variable warning: inline variables are incompatible with C++ standards before C++17
warn_cxx14_compat_nested_namespace_definition warning: nested namespace definition is incompatible with C++ standards before C++17
warn_cxx14_compat_star_this_lambda_capture warning: by value capture of '*this' is incompatible with C++ standards before C++17
warn_cxx14_compat_static_assert_no_message warning: 'static_assert' with no message is incompatible with C++ standards before C++17
warn_cxx14_compat_template_nontype_parm_auto_type warning: non-type template parameters declared with A are incompatible with C++ standards before C++17
warn_cxx14_compat_template_template_param_typename warning: template template parameter using 'typename' is incompatible with C++ standards before C++17
warn_cxx14_compat_u8_character_literal warning: unicode literals are incompatible with C++ standards before C++17
warn_cxx14_compat_using_attribute_ns warning: default scope specifier for attributes is incompatible with C++ standards before C++17
warn_cxx17_compat_multi_using_declaration warning: use of multiple declarators in a single using declaration is incompatible with C++ standards before C++17
warn_cxx17_compat_using_declaration_pack warning: pack expansion using declaration is incompatible with C++ standards before C++17
warn_for_range_begin_end_types_differ warning: 'begin' and 'end' returning different types (A and B) is incompatible with C++ standards before C++17
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