Bug 56803

Summary: g++ does not compile cast expression as (A)(B())
Product: [Retired] Red Hat Linux Reporter: Sanjeeb K Sahoo <ssahoo>
Component: gcc3Assignee: Jakub Jelinek <jakub>
Status: CLOSED RAWHIDE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 8.0   
Target Milestone: ---   
Target Release: ---   
Hardware: i586   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2004-10-02 00:57:52 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Sanjeeb K Sahoo 2001-11-27 23:37:28 UTC
From Bugzilla Helper:
User-Agent: Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)

Description of problem:
g++ does not like extra parenthesis in cast expression like (A)(B()).
It compiles this expression (A)B()  though.
A and B are two user defined types.

Version-Release number of selected component (if applicable):
gcc 2.96

How reproducible:
Always

Steps to Reproduce:
1.Write a file test.cpp with contenct as follows...
///////////////start of test case//////////////////
class B{};
class A{
public:
        operator B(){ return B(); }
};

void foo(B b) {}

void foobar() {
        foo ( (B) A()  );
        foo ( (B)(A()) ); //does not compile in g++
}
/////////////end of test case///////////
2.compile using g++ v2.96 as follows...
g++ -c -
3.
	

Actual Results:  test.cpp: In function `void foobar ()':
test.cpp:11: parse error before `)'


Expected Results:  It should have compiled without any errors.

Additional info:

It compiles with Sun CC5.0, HP aCC3.30 without errors.

Comment 1 Alan Cox 2002-12-15 18:35:08 UTC
True in 3.2 but I'm not sure its a C++ bug


Comment 2 Richard Henderson 2004-10-02 00:57:52 UTC
Fixed with gcc 3.4 c++ parser rewrite.