standards question relating to uninitialized variables

Zack Weinberg zack@rabi.columbia.edu
Sun Mar 14 14:10:00 GMT 1999


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


More information about the Gcc mailing list