Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at bugzilla.redhat.com.

Bug 92377

Summary: Code generated with "bison -y" fails with g++
Product: [Retired] Red Hat Raw Hide Reporter: John Ellson <john.ellson>
Component: bisonAssignee: Roland McGrath <roland>
Status: CLOSED DUPLICATE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 1.0CC: chabotc
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2006-02-21 18:53:28 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 John Ellson 2003-06-05 16:22:21 UTC
Description of problem:
Code generated with "bison -y" fails with g++
 
The problem originates from the fragment: /usr/share/bison/yacc.c:1116
 
    #if defined (__GNUC_MINOR__) && 2093 <= (__GNUC__ * 1000 + __GNUC_MINOR__)
      __attribute__ ((__unused__))
    #endif
 
The "__attribute__ ((__unused__))" feature is supported by gcc, but 
apparently not by g++.

Version-Release number of selected component (if applicable):
bison-1.875-2
gcc-3.2.3-4

How reproducible:
100%

Steps to Reproduce:
1.   --- test.c ---

    int main() {
    yyerrlab1:
    __attribute__ ((__unused__))
        goto yyerrlab2;
    yyerrlab2:
        return(0);
    }

2.  gcc -Wall test.c
3.  g++ -Wall test.c
    
Actual results:
gcc OK
g++ fails with:

    test.c: In function `int main()':
    test.c:4: syntax error before `goto'
    test.c:5: warning: label `yyerrlab2' defined but not used
    test.c:2: warning: label `yyerrlab1' defined but not used

Expected results:
Either g++ should support __attribute__ in the same way as gcc, or yacc.c
should take account of the different behavior.

Additional info:
g++296 fails in the same way.
Problem does not occur with bison-1.35-4, from RH8.0, which had bison.simple
instead of yacc.c.

Comment 1 John Ellson 2003-06-05 16:57:58 UTC
Also fails with g++ from today's gcc-3.3-4

Comment 2 Chris Chabot 2003-06-09 13:40:00 UTC
Verified that it also happens for me on RH9 and rawhide-current (20030609) 
with gcc-3.3-5 and bison-1.875.

Commenting out the macro from yacc.c is a workaround i gues

(ran into the problem while compiling groff)

Comment 3 Bill Nottingham 2003-07-24 22:49:04 UTC

*** This bug has been marked as a duplicate of 92262 ***

Comment 4 Red Hat Bugzilla 2006-02-21 18:53:28 UTC
Changed to 'CLOSED' state since 'RESOLVED' has been deprecated.