strange effects with enum types

Chris Torek chris at mimsy.UUCP
Thu Oct 20 20:06:43 AEST 1988


In article <143 at csaran.cs.tcd.ie> phrrngtn at cs.tcd.ie (Paul Harrington) writes:
[everything unnecessary for bug invocation deleted]
>enum{a=1,b,c}choice;
>void f(p) struct { enum{a=1,b=2,c=3}choice; }*p; {
>	printf("(f) a=%d,b=%d,c=%d\n",a,b,c); }
>main() { printf("(main) a=%d,b=%d,c=%d\n",a,b,c); f(); }

[prints
	(main) a=1,b=2,c=3
	(f) a=2,b=3,c=4
]

>why does the compiler ... produce this result and is it a bug of this
>compiler or a "feature" of C ?

The compiler is trying to be clever, and goofing.  See my fix in
comp.bugs.4bsd.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at mimsy.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.lang.c mailing list