Re: unreachable code in 'vector'
- From: Jerry Coffin <jcoffin@xxxxxxxxx>
- Date: Thu, 26 May 2005 07:56:21 -0600
In article <ekoP1pTYFHA.228@xxxxxxxxxxxxxxxxxxxx>, spoo@xxxxxxxxx
says...
[ ... ]
> Well thanks for the information. This is not what I would have
> expected. I would have thought that this warning would have
> been emitted without optimization. I assumed (probably
> incorrectly given your explanation) that the code was being
> optimized out, sort of like saying if(false) { ...}
>
> It certainly seems this way in other places.
> It's only the one in vector that the OP posted
> that I've seen that has different behavior based
> on the build settings.
The warning _can_ be emitted in a debug build if the unreachability
of the code is sufficiently "obvious" -- something like 'if (false)'
will show up essentially every time. OTOH, consider something like
this:
bool x = false;
if (x) {
whatever();
}
Now, it's pretty obvious to you or me that x will be false when the
if statement is executed, so the call to whatever() is unreachable --
but I doubt there's a compiler around that will detect that with
optimization turned off.
In all honesty, I'm not sure there's one that will detect it with
optimization turned ON either, but that's more or less irrelevant --
the point is that it _could_ be detected, but almost certainly
wouldn't be without optimization. Past that, it's mostly a matter of
what kinds of things a particular optimizer looks at, which can be
somewhat difficult to predict (to put it mildly).
Doing a quick test with the current MS compiler on this code, a
glance at the object code shows that it DOES detect that the call is
unreachable, but doesn't issue a warning to say so...
--
Later,
Jerry.
The universe is a figment of its own imagination.
.
- Follow-Ups:
- Re: unreachable code in 'vector'
- From: Duane Hebert
- Re: unreachable code in 'vector'
- References:
- unreachable code in 'vector'
- From: Larry Waibel
- Re: unreachable code in 'vector'
- From: Duane Hebert
- Re: unreachable code in 'vector'
- From: Larry Waibel
- Re: unreachable code in 'vector'
- From: Duane Hebert
- Re: unreachable code in 'vector'
- From: Jerry Coffin
- Re: unreachable code in 'vector'
- From: Duane Hebert
- unreachable code in 'vector'
- Prev by Date: edittext without border
- Next by Date: Re: How to remove linking warning LNK4089
- Previous by thread: Re: unreachable code in 'vector'
- Next by thread: Re: unreachable code in 'vector'
- Index(es):
Relevant Pages
|