public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/40283] New: [C++0x] Context-specific explicit conversion doesn't work
@ 2009-05-28 13:40 piotr dot wyderski at gmail dot com
2009-10-07 19:36 ` [Bug c++/40283] " jason at gcc dot gnu dot org
0 siblings, 1 reply; 2+ messages in thread
From: piotr dot wyderski at gmail dot com @ 2009-05-28 13:40 UTC (permalink / raw)
To: gcc-bugs
std::unique_ptr has an explicit conversion to
bool operator. However, according to Wikipedia:
http://en.wikipedia.org/wiki/C%2B%2B0x#Explicit_conversion_operators
In C++0x, the explicit keyword can now be applied to conversion operators. As
with constructors, it prevents the use of those conversion functions in
implicit conversions. However, language contexts that specifically require a
boolean value (the conditions of if-statements and loops, as well as operands
to the logical operators) count as explicit conversions and can thus use a bool
conversion operator.
But the following code doen't compile:
#include <stdio.h>
#include <memory>
int main(int argc, char *argv[]) {
std::unique_ptr<int> p(0);
if (p) {}
return 0;
}
Results in:
$ gcc -std=gnu++0x testcase.cpp
testcase.cpp: In function 'int main(int, char**)':
testcase.cpp:10: error: could not convert 'p' to 'bool'
--
Summary: [C++0x] Context-specific explicit conversion doesn't
work
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: piotr dot wyderski at gmail dot com
GCC host triplet: Cygwin/GCC-trunk rev. 147886
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40283
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/40283] [C++0x] Context-specific explicit conversion doesn't work
2009-05-28 13:40 [Bug c++/40283] New: [C++0x] Context-specific explicit conversion doesn't work piotr dot wyderski at gmail dot com
@ 2009-10-07 19:36 ` jason at gcc dot gnu dot org
0 siblings, 0 replies; 2+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-10-07 19:36 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from jason at gcc dot gnu dot org 2009-10-07 19:36 -------
Fixed for 4.5 (a few weeks ago).
--
jason at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40283
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-10-07 19:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-28 13:40 [Bug c++/40283] New: [C++0x] Context-specific explicit conversion doesn't work piotr dot wyderski at gmail dot com
2009-10-07 19:36 ` [Bug c++/40283] " jason at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).