[Bug c++/82146] if (&pdo) is always true error
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Sep 8 14:59:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82146
--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to MaaSoftware from comment #5)
> Ok.
>
> I am sorry,
> return MyFunc(Num, *(CMaaString *)NULL, doc); // produces GPF in calling
> method not here.
So what? Dereferencing a null pointer has undefined behaviour, so anything can
happen. It could crash immediately, or it could produce unexpected results
elsewhere in the program.
> I have think before what all references are object memory pointers inside
> compiller,
You are wrong.
> just it is more easy working with references of objects not with
> pointers in most ways.
But references can't be null, so if you need something that can be null you
must use a pointer. It's quite simple, please stop wasting our time.
> And no warning generated to *(CMaaString *)NULL code.
> CXXFLAGS = -pipe -W -O3 -fpermissive
Just because there's no warning doesn't mean the code is correct.
More information about the Gcc-bugs
mailing list