Re: Reference to show that if (this == NULL) implies undefined
behaviour
On 2011-11-10 19:11:44 +0000, Carlos Moreno said:
On 11-11-09 03:58 PM, Pete Becker wrote:
[ ... ] In the original example (no
inheritance, no virtual functions involved) there's no good reason for
a compiler to generate code that does unexpected things.
Huh??? (care to elaborate on how exactly you define "unexpected"
in the above sentence?? :-) )
What do you mean "no good reason"??? You don't find the fact that
this *is not allowed to be NULL* reason enough for the compiler to
optimize away that if, thus guaranteeing that the program will
crash ???
Gosh, you're cherry-picking from my response. But, yes, optimization is
perhaps a good reason. What I was pointing out is that this typically
works, but is not guaranteed. Which is, if I recall correctly, what I
explicitly said in text that you snipped.
--
Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The
Standard C++ Library Extensions: a Tutorial and Reference
(www.petebecker.com/tr1book)
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]