Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.c++.moderated    |    Moderated discussion of C++ superhackery    |    33,346 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 31,660 of 33,346    |
|    Carlos Moreno to Pete Becker    |
|    Re: Reference to show that if (this == N    |
|    10 Nov 11 11:11:44    |
      From: moreno_news@mailinator.com              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 ???              True, the examples given by the previous poster did not really       address the this pointer, and it was mainly situations where       the sequence of executed statements is what hints the compiler       about "impossibility" of a pointer being NULL. But still, if       indeed (or I should say, *given that* indeed) the this pointer       *is not allowed* to take the NULL value, then it seems perfectly       reasonable for the compiler to replace if (this == NULL) with       if (false), including entirely removing the corresponding block       associated to that if.              Am I missing something??              Carlos       --       PS: Notice that, from the point of view of my original post,        the argument by the previous poster is not completely        useful, in that I was trying to convince someone that        allowing a situation where this == NULL is not legal;        the argument by the previous poster goes more along the        lines of presenting an example that shows why that        particular instance of UB *can* have consequences in        real-life situations. (but if the person is not convinced        that it *is* UB, then the example would tell him nothing.        Just a remark --- I highly appreciated the example!!)                     --        [ See http://www.gotw.ca/resources/clcm.htm for info about ]        [ comp.lang.c++.moderated. First time posters: Do this! ]              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca