Issue Details (XML | Word | Printable)

Key: PCC-386
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Minor Minor
Assignee: Anders Magnusson
Reporter: Iain Hibbert
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
pcc

enum declaration before definition causes compiler error

Created: 16/Mar/12 06:39 PM   Updated: 18/Mar/12 01:27 PM
Component/s: C frontend
Affects Version/s: None
Fix Version/s: None

Environment: NetBSD/i386


 Description  « Hide
While attempting to compile GDB 7.3.1 I discovered an error

/var/cvs/NetBSD-current/src/external/gpl3/gdb/dist/gdb/i386-tdep.c, line 7187: warning: implicit conversion of argument 2 due to prototype
/var/cvs/NetBSD-current/src/external/gpl3/gdb/dist/gdb/i386-tdep.c, line 7187: compiler error: strmemb

examining this in detail showed that include file ordering means that
an enum is being referenced in a function prototype before its definition
(which according to C99 6.7.2.3 note 3 is not allowed), but the following code
snippet

  void foo(enum bar);

  enum bar { A, B, C };

  void main(void)
  {
      foo(B);
  }

when compiled results in

  test.c: line 7: compiler error: strmemb

rather than a useful warning or error.

 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Anders Magnusson made changes - 17/Mar/12 05:52 PM
Field Original Value New Value
Assignee Anders Magnusson [ ragge ]
Anders Magnusson made changes - 17/Mar/12 05:54 PM