Title
Integral to bool conversion in converted constant expressions
Status
nad
Section
7.7 [expr.const]
Submitter
Richard Smith

Created on 2011-10-21.00:00:00 last changed 156 months ago

Messages

Date: 2012-02-15.00:00:00

Rationale (February, 2012):

The analysis is correct, and the example is ill-formed. Implementations that accept it are in error.

Date: 2022-11-20.07:54:16

The following example appears to be ill-formed, although current implementations accept it:

  template<bool> struct S { };
  S<0> s;

The reason this is ill-formed is that the non-type template argument is a converted constant expression of type bool (see 13.4.3 [temp.arg.nontype] paragraph 5), and the second conversion in the implicit conversion sequence is a boolean conversion, which is not allowed in the conversion for a converted constant expression (see 7.7 [expr.const] paragraph 3) . Conversions in the other direction (from bool to integer types) are permitted here, since they're integral promotions.

History
Date User Action Args
2012-02-27 00:00:00adminsetmessages: + msg3843
2012-02-27 00:00:00adminsetstatus: open -> nad
2011-10-21 00:00:00admincreate