Bug ID: 30460
           Summary: Initializing global pointer to nullptr instead of 0
                    triggers global constructor warning
           Product: clang
           Version: 3.7
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
    Classification: Unclassified

The following code snippet triggers a warning when -Wglobal-constructors is set
(specifically: "warning: declaration requires a global constructor"):

  #include <cstddef>
  void *global = nullptr;

In contrast, this does not trigger the warning:

  #include <cstddef>
  void *global = 0;

I am quite surprised by this. I naively expected the two snippets to compile
down to the same machine code.

Indeed, with -O3 set, I get identical .o file.

The issue exists at least in clang++ 3.7 and 3.9.

You are receiving this mail because:
You are on the CC list for the bug.
llvm-bugs mailing list

Reply via email to