[Bug c/18930] New: name clash in C?

2004-12-10 Thread jacob at engelbrecht dot dk
On several different version of gcc (2.95, 3.3 and 3.4)
(gcc-3.4 --version reports: gcc-3.4 (GCC) 3.4.2 (Debian 3.4.2-2))
When I compile a.c I get errors:

a.c:6: error: parse error before c
etc

but b.c compiles without errors. As I understand the ANSI-C standard,
type names and variable names should be separate namespaces - and both
programs should compile (borland turbo C 2.01 compiles both programs).

== a.c ==
#include stdio.h

typedef int i;
typedef char c;

i main (i c, c ** v)
{
  i i=1;
  printf(%d\n,c+i);
  return 0;
}

== b.c ==
#include stdio.h

typedef int i;
typedef char c;

i main (i C, c ** v)
{
  i i=1;
  printf(%d\n C+i);
  return 0;
}

-- 
   Summary: name clash in C?
   Product: gcc
   Version: 3.4.2
Status: UNCONFIRMED
  Severity: normal
  Priority: P2
 Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jacob at engelbrecht dot dk
CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18930


[Bug c/18930] name clash in C?

2004-12-10 Thread jacob at engelbrecht dot dk

--- Additional Comments From jacob at engelbrecht dot dk  2004-12-10 23:30 
---
Then I do not understand why the second program is legal?
(After a bit of experimentation I found out that if the type name is used as
variable name then it can not be used as a typename again). I would
Think that either type names are in the same name space as variable names, and
then both programs should be erronous (This I think is correct after rereading K
 R), or they are in different namespaces and then both programs should be
correct (although it might be difficult or impossible to implement). 

The following piece of code does not bark when compiled unless JE is defined

typedef int i;
i main()
{
  i i;
#ifdef JE
  i p;
#endif
  return i = 1;
}

regards

Jacob

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18930