Re: possible unnamed temporary problem? by maxk
maxk
Sun Feb 27 06:56:22 CST 2005
Hey guys,
I have been around the block for at least a little while and do not
need to be patronized here. I would have never posted this code or
suspected the compiler without stepping into the code. Nothing remotely
dangerous happens in this code (other than possibly
LNTableMsg(vect[i]), which calls into a 3d party lib, so who knows). I
remember unnamed temps being mentioned as a problem in at least one
version of msvc, and wanted to confirm my recollection.
'the boy who cried "compiler!"'
Larry Brasfield wrote:
> "max khesin" <max@nospam.com> wrote in message
> news:uMZ7oI3GFHA.3648@TK2MSFTNGP09.phx.gbl...
> > Hi,
> > I have code that goes something like
> > LNstring s = LNstring::convert(i) + ":" +
LNTableMsg(vect[i]).toStr() + LNLog::getMsgFieldSeparator();
> > and causes a crash. Stepping it through the debugger I noticed that
the statements are executed in the following order:
> > 1) LNLog::getMsgFieldSeparator()
> > 2) LNTableMsg::LNTableMsg(vect[i])
> > 3) LNstring::convert(i)
> > Crash!!!
> > I was wondering if there is a possible compiler issue here with
MSVC's handling of unnamed variable LNTableMsg (hence .toStr() was
> > never called)
> >
> > Any info is appreciated!
> > thanks,
>
>
> I concur with Victor on this, but I'll add a comment to
> help free your mind of compiler suspicion.
>
> The order of evaluation you mention above is fully within
> the latitude granted to implementers by the C++ standard.
>
> As someone who has unearthed a few code generation
> bugs, I remain convinced that, unless you are an extremely
> expert programmer, (smarter than most people I have met),
> the compiler should be the last place to focus your suspicion,
> not the first. The "Crash!!!" (whatever that means) is much
> more likely to be your doing rather than the compiler's.
>
> --
> --Larry Brasfield
> email: donotspam_larry_brasfield@hotmail.com
> Above views may belong only to me.