c++/5666: ICE compiling old style C code with g++

reichelt@igpm.rwth-aachen.de reichelt@igpm.rwth-aachen.de
Tue Feb 12 07:06:00 GMT 2002


>Number:         5666
>Category:       c++
>Synopsis:       ICE compiling old style C code with g++
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          ice-on-illegal-code
>Submitter-Id:   net
>Arrival-Date:   Tue Feb 12 06:46:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Volker Reichelt
>Release:        gcc version 3.1 20020204 (experimental)
>Organization:
>Environment:
mips-sgi-irix6.5, i686-pc-linux-gnu
>Description:
The following code snippet is legal old-style C code.
However, it is illegal C++ code. In fact it will cause
an ICE, when compiled with g++:

------------------------snip here-----------------------
void foo (i, j)
    int i;
    int j;
{
    quus(j);
    quus(j);
}

void bar (k)
    int k;
{
    int l;
    struct { int a[3]; } j;
}
------------------------snip here-----------------------

The error message reads:

OldStyle.cpp:1: `i' was not declared in this scope
OldStyle.cpp:1: `j' was not declared in this scope
OldStyle.cpp:2: variable or field `foo' declared void
OldStyle.cpp:2: initializer list being treated as compound expression
OldStyle.cpp:2: syntax error before `int'
OldStyle.cpp:4: parse error before `{' token
OldStyle.cpp:6: ISO C++ forbids declaration of `quus' with no type
OldStyle.cpp:7: parse error before `}' token
OldStyle.cpp:9: `k' was not declared in this scope
OldStyle.cpp:10: variable or field `bar' declared void
OldStyle.cpp:10: syntax error before `int'
OldStyle.cpp:13: conflicting types for `<anonymous struct> j'
OldStyle.cpp:3: previous declaration as `int j'
OldStyle.cpp:14: parse error before `}' token
OldStyle.cpp: In function `void __static_initialization_and_destruction_0(int, 
   int)':
OldStyle.cpp:6: Internal compiler error in emit_move_insn, at expr.c:2748
Please submit a full bug report, [etc.]

Remark: Be sure that the file has an extension like
.cpp .cc .ii and not .c or .i (otherwise you'll invoke
the C front-end, even if you use g++).
>How-To-Repeat:
g++ -c OldStyle.cpp
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-bugs mailing list