Re: try...catch and local variables

Tech-Archive recommends: Speed Up your PC by fixing your registry



Peter Duniho <NpOeStPeAdM@xxxxxxxxxxxxxxxx> wrote:

<snip>

I wonder if the compiler/framework will barf on that too? :) Most
likely...

That is more like the compiler bug I was talking about. I haven't tried
that exact construct, but I have written code where it is provable that the
variable *is* initialized prior to access, and yet the compiler complains
that it isn't. In these cases (such as your example, and the other examples
I've seen), adding the initialization required to get the compiler to stop
complaining can actually result in what is effectively an uninitialized
value bug, because the otherwise-unnecessary initialization hides any other
problems with initialization.

It's not a compiler bug. The compiler is working exactly to the
language specification, as it should do.

Now, if you want to complain that the language specification is
"wrong" - the specification is already fairly complicated in terms of
working out precisely when a variable is definitely assigned. I believe
it is much better to make a language slightly "dumber" but simpler to
reason about (i.e. simpler to make sure the compiler is correct,
simpler to make sure the specification doesn't let some oddities
through etc) than to try to make it incredibly smart.

--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
.



Relevant Pages

  • Re: try...catch and local variables
    ... That is more like the compiler bug I was talking about. ... variable *is* initialized prior to access, and yet the compiler complains ... adding the initialization required to get the compiler to stop ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: pointer components and memory leaks
    ... that's the same thing as what Paul said. ... Let's not suggest compiler bug every time one finds a problem. ... leak memory, though even there, user bugs in other parts of the code can ...
    (comp.lang.fortran)
  • Re: try...catch and local variables
    ... > It's not a compiler bug. ... The compiler is working exactly to the ... I don't have a copy of the language specification. ... (I don't have a public link to a 2.0 spec handy.) ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Really wierd bug
    ... > it has to be a compiler bug because it works fine for other population ... > My compiler is Compaq Visual Fortran 1997-1999. ... > with allocating the array sizes because I've defined the arrays as ... your program does indeed contain an array bounds error -- this ...
    (comp.lang.fortran)
  • Re: Questions in Optimization !!
    ... that the problem is absolutely, positively not a compiler bug, because ... "But it works as long as I don't use optimization! ... resulting in stack corruption ...
    (comp.os.vxworks)