Bug 56803 - g++ does not compile cast expression as (A)(B())
Summary: g++ does not compile cast expression as (A)(B())
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: gcc3
Version: 8.0
Hardware: i586
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2001-11-27 23:37 UTC by Sanjeeb K Sahoo
Modified: 2007-04-18 16:38 UTC (History)
0 users

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2004-10-02 00:57:52 UTC
Embargoed:


Attachments (Terms of Use)

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.


Note You need to log in before you can comment on or make changes to this bug.