Will I be able to declare a constexpr lambda inside a template parameter?

No, that is a compiler bug. gcc 7.1 correctly rejects the code. [expr.prim.lambda]/2: A lambda-expression is a prvalue whose result object is called the closure object. A lambda-expression shall not appear in an unevaluated operand, in a template-argument, in an alias-declaration, in a typedef declaration, or in the declaration of a function or function template … Read more

C++ operator % guarantees

In addition to Luchian‘s answer, this is the corresponding part from the C++11 standard: The binary / operator yields the quotient, and the binary % operator yields the remainder from the division of the first expression by the second. If the second operand of / or % is zero the behavior is undefined. For integral … Read more

What do the C and C++ standards say about bit-level integer representation and manipulation?

(1) If all the bits in an integer type are zero, does the integer as whole represent zero? Yes, the bit pattern consisting of all zeroes always represents 0: The representations of integral types shall define values by use of a pure binary numeration system.49 [§3.9.1/7] 49 A positional representation for integers that uses the … Read more

Can we apply content not explicitly cited from the normative references to the C++ standard?

The function of the Normative References section of an ISO standard document is defined in ISO/IEC Directives, Part 2, 2011 §6.2.2: 6.2.2 Normative references This conditional element shall give a list of the referenced documents cited (see 6.6.7.5) in the document in such a way as to make them indispensable for the application of the … Read more

Calling an explicit constructor with a braced-init list: ambiguous or not?

As far as I can tell, this is a clang bug. Copy-list-initialization has a rather unintuitive behaviour: It considers explicit constructors as viable until overload resolution is completely finished, but can then reject the overload result if an explicit constructor is chosen. The wording in a post-N4567 draft, [over.match.list]p1 In copy-list-initialization, if an explicit constructor … Read more

Is it a strict aliasing violation to alias a struct as its first member?

The behaviour of the cast comes down to [expr.static.cast]/13; A prvalue of type “pointer to cv1 void” can be converted to a prvalue of type “pointer to cv2 T”, where T is an object type and cv2 is the same cv-qualification as, or greater cv-qualification than, cv1. If the original pointer value represents the address … Read more

Observable behavior and undefined behavior — What happens if I don’t call a destructor?

I simply do not understand what “depends on the side effects” means. It means that it depends on something the destructor is doing. In your example, modifying *p or not modifying it. You have that dependency in your code, as the output would differ if the dctor wouldn’t get called. In your current code, the … Read more

Returning struct containing array

I believe the behavior is undefined both in C89/C90 and in C99. foo().f is an expression of array type, specifically char[25]. C99 6.3.2.1p3 says: Except when it is the operand of the sizeof operator or the unary & operator, or is a string literal used to initialize an array, an expression that has type “array … Read more