Bug 12163

Summary: [3.3/3.4 regression] static_cast + explicit ctor regression
Product: gcc Reporter: Vladimir Prus <vladimir>
Component: c++Assignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: critical CC: gcc-bugs, vladimir
Priority: P2    
Version: 3.3.2   
Target Milestone: 3.3.2   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2003-09-04 14:19:36

Description Vladimir Prus 2003-09-04 06:18:32 UTC
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.
Comment 1 Wolfgang Bangerth 2003-09-04 14:19:36 UTC
I don't have a recent 3.3 snapshot around, but I can confirm that it worked in 3.3.0 and 
a may snapshot of mainline, while it is broken with present mainline. So it's a regression 
in any case. 
 
W. 
Comment 2 Andrew Pinski 2003-09-04 14:38:03 UTC
From Phil's regression hunter: Search converges between 2003-06-25-trunk (#324) and 2003-
06-26-trunk (#325).
: Search converges between 2003-06-25-3.3 (#149) and 2003-06-26-3.3 (#150).
Comment 3 GCC Commits 2003-09-05 18:04:32 UTC
Subject: Bug 12163

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	mmitchel@gcc.gnu.org	2003-09-05 18:04:22

Modified files:
	gcc/cp         : ChangeLog call.c pt.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/expr: static_cast4.C 
	gcc/testsuite/g++.dg/template: crash9.C 

Log message:
	PR c++/12163
	* call.c (perform_direct_initialization): Correct logic for
	direct-initialization of a class type.
	
	PR c++/12146
	* pt.c (lookup_template_function): Robustify.
	
	PR c++/12163
	* g++.dg/expr/static_cast4.C: New test.
	
	PR c++/12146
	* g++.dg/template/crash9.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3648&r2=1.3649
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/call.c.diff?cvsroot=gcc&r1=1.430&r2=1.431
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.774&r2=1.775
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3026&r2=1.3027
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/expr/static_cast4.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/crash9.C.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 4 GCC Commits 2003-09-05 18:31:21 UTC
Subject: Bug 12163

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_3-branch
Changes by:	mmitchel@gcc.gnu.org	2003-09-05 18:31:19

Modified files:
	gcc/cp         : ChangeLog call.c pt.c 
	gcc/testsuite  : ChangeLog 

Log message:
	PR c++/12163
	* call.c (perform_direct_initialization): Correct logic for
	direct-initialization of a class type.
	
	PR c++/12146
	* pt.c (lookup_template_function): Robustify.
	
	PR c++/12163
	* g++.dg/expr/static_cast4.C: New test.
	
	PR c++/12146
	* g++.dg/template/crash9.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.3076.2.198&r2=1.3076.2.199
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/call.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.341.2.30&r2=1.341.2.31
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.635.2.35&r2=1.635.2.36
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.2261.2.266&r2=1.2261.2.267

Comment 5 Mark Mitchell 2003-09-05 18:36:04 UTC
Fixed in GCC 3.3.2, GCC 3.4.