msvc branch

Adam Goode agoode at andrew.cmu.edu
Tue May 11 11:28:50 EDT 2010


On 05/06/2010 01:15 PM, Hauke Heibel wrote:
> I introduced the scope stuff due to the 'goto' declarations. GCC
> complains without it. I think it is because of the following scenario.
> In the example below, foo goes out of scope at the end of the function
> and thus the compiler must take care of proper destruction. The
> problem is that the goto statement skips the initialization of the
> object to be destroyed which may lead to problems, so GCC barfs.
> 
> void bar()
> {
> goto FAIL;
>   int foo = 0;
> FAIL:
>   return false;
> }
> 
> There are two options to resolve this. Either put the variable in its
> own scope which should end before the label FAIL or move the
> initialization to the top of the function. In the beginning I opted
> for the scope but as soon as you have many goto statements it becomes
> intractable - the only sane option is to move the initialization of
> the variable to the top of the function (before the first goto call).
> The scope thing which you saw is a left-over and could be replaced by
> moving the variables. Anyways, it should not hurt.


Interesting, gcc was working ok for me here. Are you compiling with g++?
That might be more sensitive. In C there is no destruction required, it
just moves the stack pointer and nothing uninitialized is ever touched.


Adam

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 261 bytes
Desc: OpenPGP digital signature
Url : http://lists.andrew.cmu.edu/pipermail/openslide-users/attachments/20100511/66e812d4/attachment.bin 


More information about the openslide-users mailing list