This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/12163] New: static_cast + explicit ctor regression
- From: "ghost at cs dot msu dot su" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 4 Sep 2003 06:18:34 -0000
- Subject: [Bug c++/12163] New: static_cast + explicit ctor regression
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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.