Why is there no multiple definition error when you define a class in a header file?

The one-definition rule (3.2, [basic.def.odr]) applies differently to classes and functions: 1 – No translation unit shall contain more than one definition of any variable, function, class type, enumeration type, or template. […] 4 – Every program shall contain exactly one definition of every non-inline function or variable that is odr-used in that program […] … Read more

Static constexpr odr-used or not?

TryMe::arr is odr-used but you don’t provide a definition (see it live): constexpr int TryMe::arr[1]; Why is the result inconsistent between gcc and clang? This is because odr violations do not require a disagnostic, from both the C++11 and C++14 draft standard (emphasis mine): Every program shall contain exactly one definition of every non-inline function … Read more