https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65168

            Bug ID: 65168
           Summary: diagnostic: missing: reference cannot be bound to
                    dereferenced null pointer
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jan.kratochvil at redhat dot com
            Target: x86_64-linux-gnu

int main() {
  int *p=static_cast<int *>(0),&r=*p;
  return !&r;
}

-Wall

g++ (GCC) 5.0.0 20150221 (experimental)
<nothing>

clang++ (clang-3.5.0-6.fc21.x86_64):
ref.C:3:12: warning: reference cannot be bound to dereferenced null pointer in
well-defined C++ code; pointer may be assumed to always convert to true
[-Wundefined-bool-conversion]

I have no idea if it can be miscompiled by either compiler.  Still I find
useful to be notified I write non-conforming C++ code.

Reply via email to