Explicit specialization in non-namespace scope does not compile in GCC

This should be a GCC bug. Full specialization should be allowed in any scope, including in class definition. According to CWG 727, [temp.expl.spec] paragraph 2 was changed from (emphasis mine) An explicit specialization shall be declared in a namespace enclosing the specialized template. An explicit specialization whose declarator-id or class-head-name is not qualified shall be … Read more

Is the `this` argument evaluated before or after other member function arguments?

This is still undefined behavior (UB) as per expr.compound: The postfix-expression is sequenced before each expression in the expression-list and any default argument. The initialization of a parameter, including every associated value computation and side effect, is indeterminately sequenced with respect to that of any other parameter. (emphasis mine) This means that the postfix expression … Read more

Using void (*)() pointers for other functions

In this particular case, the calls are legal. Section 6.7.6.3p15 of the C standard spells out what makes two function type compatible (relevant part in bold): For two function types to be compatible, both shall specify compatible return types. Moreover, the parameter type lists, if both are present, shall agree in the number of parameters … Read more

Is std::string guaranteed not to give back memory spontaneously?

No guarantee whatsoever. [string.cons]/36 defines assigning a const char* to an std::string in term of a move-assignment, whose definition is: [string.cons]/32 basic_string& operator=(basic_string&& str) noexcept(/*…*/) Effects: Move assigns as a sequence container, except that iterators, pointers and references may be invalidated. This shows that the Committee let the implementation choose freely between an invalidating operation … Read more

Does UINT_MAX have all bits set to 1?

In C, the maximum value for an unsigned integer must be in the form1: 2N – 1. Thus all value bits of the value UINT_MAX will be set to 1. There may be padding bits, whose values are unspecified. 1 (Quoted from: ISO/IEC 9899:201x 6.2.6.2 Integer types 1) For unsigned integer types other than unsigned … Read more

Is this change in overload resolution between Clang 3.5 and 3.6 correct or a bug?

I believe Clang is correct to produce this error: The [temp.inst] section of the C++ standard in paragraph 10 says: If a function template or a member function template specialization is used in a way that involves overload resolution, a declaration of the specialization is implicitly instantiated (14.8.3). Forming the implicit conversion sequence necessary to … Read more

GCC and Clang template call resolution differences

According to overload resolution, there are two viable functions: The specialization of the global operator|-template with deduced arguments and the specialization of the member operator function template. Both have the same signature – the member function template has an implicit object parameter of type Alice const& (see ยง13.3.1/4). So both viable functions (after template argument … Read more

Understanding the C11 type hierarchy

The cluttered structure of C11 types resulting from the second step of the question can be simplified by removal/reduction of less important nodes and delegating some redundant/subsidiary information to be presented by other means. I propose the following five-step algorithm for that: Removal of all extended integer types (strictly conforming implementation assumed); Reduction of the … Read more

How does the number of braces affect uniform initialization?

Overload resolution is fun like this. {a} has exact match rank for initializing (a temporary for) the const A& parameter, which outcompetes the user-defined conversion B(const A&) as a realization of {a}. This rule was added in C++14 to resolve ambiguities in list-initialization (along with adjustments for aggregates). Note that the notional temporary is never … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)