Bug 56803 - g++ does not compile cast expression as (A)(B())
g++ does not compile cast expression as (A)(B())
Status: CLOSED RAWHIDE
Product: Red Hat Linux
Classification: Retired
Component: gcc3 (Show other bugs)
8.0
i586 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2001-11-27 18:37 EST by Sanjeeb K Sahoo
Modified: 2007-04-18 12:38 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2004-10-01 20:57:52 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Sanjeeb K Sahoo 2001-11-27 18:37:28 EST
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 13:35:08 EST
True in 3.2 but I'm not sure its a C++ bug
Comment 2 Richard Henderson 2004-10-01 20:57:52 EDT
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.