From 394330824772980108
X-Google-Thread: f78e5,473009b7dc4fc05d,start
X-Google-NewGroupId: yes
X-Google-Attributes: gid7894ca11fe,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
Received: by 10.68.31.73 with SMTP id y9mr8938691pbh.0.1319063059885;
        Wed, 19 Oct 2011 15:24:19 -0700 (PDT)
MIME-Version: 1.0
Path: d5ni33477pbc.0!nntp.google.com!news1.google.com!volia.net!news2.volia.net!feed-A.news.volia.net!news.musoftware.de!wum.musoftware.de!news.albasani.net!.POSTED!not-for-mail
From: "Richard Smith"<richard@metafoo.co.uk>
Newsgroups: comp.std.c++
Subject: Defect report: integral-to-boolean conversion in converted      
 constant expressions
Date: Wed, 19 Oct 2011 15:24:18 -0700 (PDT)
Organization: unknown
Lines: 28
Sender: std-cpp-request@vandevoorde.com
Approved: stephen.clamage@oracle.com
Message-ID: <37779.10.0.7.178.1319061824.squirrel@webmail.secure.aluminati.net>
Reply-To: richard@metafoo.co.uk
X-Trace: news.albasani.net dbjeXRGEzaD8h3UPmbZtnYcOzyckvbfAiHryhC8Md0qmnejuPWNhod0nQOUtfOe3WZfGJUgJbl6ltT8O9l70HA==
NNTP-Posting-Date: Wed, 19 Oct 2011 22:24:19 +0000 (UTC)
Injection-Info: news.albasani.net; logging-data="OO3ptdRd1wguv224Xx63YzX7CmpQ0jDBAPPEqHQdAq4aflGddveFC3fBBoQk4UgW62Gi0+AxEitKh3A+HsM6WJSTO+gcxSHI+vSFaIqvLDeR3r4An7Eere5U4G51my5o"; mail-complaints-to="abuse@albasani.net"
X-Mailer: Perl5 Mail::Internet v2.05
X-Submission-Address: std-cpp-submit@vandevoorde.com
Cancel-Lock: sha1:uBAMPZZa5U/mwhwJq654CX5/9Gc=
X-Original-Date: Wed, 19 Oct 2011 23:03:44 +0100 (BST)
Xref: news1.google.com comp.std.c++:3472
Content-Type: text/plain;charset=iso-8859-1

Hi,

In both C++98 and C++11, the following code appears to be ill-formed:

   template<bool b>  struct S {};
   S<0>  s;

However, EDG, g++ and clang all accept it. The reason this is ill-formed is
that the non-type template argument is a converted constant expression of type
'bool' (see [temp.arg.nontype]p5), 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 [expr.const]p3).
Conversions in the other direction (from 'bool' to integer types) are
permitted here, since they're integral promotions.

Suggested resolution: In [expr.const]p3, add "boolean conversions from
integral or unscoped enumeration type other than narrowing conversions" to the
list of conversions allowed in a converted constant expression.

Thanks,
Richard


-- 
[ comp.std.c++ is moderated.  To submit articles, try posting with your ]
[ newsreader.  If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]


