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]

Re: Some C++ questions


> 
> Here are a couple of C++ scoping questions I have.
> 
> 1)
> 
> int main()
> {
>   if (int i = 10)
>     i++; // should be okay
>   i++; // shold be out of scope
> }

EGCS does not complain about this, even though it is wrong. 
However, it does complain about

	int main()
	{
		if (int i = 10)
			i++;
		++i;
	}

Something funny happens about scoping around the if.  While
this probably isn't a bug (since it doesn't generate incorrect
code since the i++ doesn't do anything) it certainly is a quirk.

-- 
Ross Alexander                       r.alexander@auckland.ac.nz
Department of Statistics
University of Auckland
New Zealand



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