[llvm-bugs] [Bug 30460] New: Initializing global pointer to nullptr instead of 0 triggers global constructor warning

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Sep 20 02:23:15 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=30460

            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
          Assignee: unassignedclangbugs at nondot.org
          Reporter: max at quendi.de
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
    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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160920/2b04d673/attachment.html>


More information about the llvm-bugs mailing list