[Bug c++/12163] New: static_cast + explicit ctor regression
ghost at cs dot msu dot su
gcc-bugzilla@gcc.gnu.org
Thu Sep 4 06:18:00 GMT 2003
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12163
Summary: static_cast + explicit ctor regression
Product: gcc
Version: 3.3.2
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: ghost at cs dot msu dot su
CC: gcc-bugs at gcc dot gnu dot org
Using
gcc version 3.3.2 20030831 (Debian prerelease)
I get compile error on the following code:
class C {
public:
explicit C(int) {}
};
int main()
{
int i = 0;
static_cast<C>(i);
return 0;
}
The error is:
bash-2.05b$ g++ ex.cpp
ex.cpp: In function `int main()':
ex.cpp:10: error: invalid static_cast from type `int' to type `C'
It works in 3.2. It seems that 'static_cast' is rather explcit, so the ctor
should be used.
More information about the Gcc-bugs
mailing list