Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | "Richard Smith"<richard@metafoo.co.uk> |
|---|---|
| Newsgroups | comp.std.c++ |
| Subject | Defect report: integral-to-boolean conversion in converted constant expressions |
| Date | 2011-10-19 15:24 -0700 |
| Organization | unknown |
| Message-ID | <37779.10.0.7.178.1319061824.squirrel@webmail.secure.aluminati.net> (permalink) |
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 ]
Back to comp.std.c++ | Previous | Next — Next in thread | Find similar
Defect report: integral-to-boolean conversion in converted constant expressions "Richard Smith"<richard@metafoo.co.uk> - 2011-10-19 15:24 -0700 Re: Defect report: integral-to-boolean conversion in converted constant expressions Daniel Krügler<daniel.kruegler@googlemail.com> - 2011-10-25 09:59 -0700
csiph-web