This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

standards question relating to uninitialized variables



Given this code:

extern void use(int);

enum foo
{
    a = 0, b, c, d
};

void
func(enum foo bar)
{
    int x;
    
    if(bar == a)
	x = 0;
    else if(bar == b)
	x = 4;
    else if(bar == c)
	x = 9;
    else if(bar == d)
	x = 16;

    use(x);
}

Is GCC allowed to assume that `bar' has one of the defined enumeration
values when compiling C? What about C++?

zw


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]