This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/12163] New: static_cast + explicit ctor regression


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]