[LLVMbugs] [Bug 22565] New: static constexpr floating member incorrectly identified as odr-used

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Feb 12 07:40:33 PST 2015


http://llvm.org/bugs/show_bug.cgi?id=22565

            Bug ID: 22565
           Summary: static constexpr floating member incorrectly
                    identified as odr-used
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: yaghmour.shafik at gmail.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Given the following code from stackoverflow question
http://stackoverflow.com/q/28264279/1708801 :

struct Blob {
    static constexpr double a = 10;
};

int main() {
    Blob b;
    auto c = b.a;
}

Does not link and produces the following error:

  prog.cc:(.text+0xb): undefined reference to `Blob::a' clang: error: linker   
command failed with exit code 1 (use -v to see invocation)

Here is a online live version:

  http://melpon.org/wandbox/permlink/JRphxTSHekwqEd6p

This looks like an odr-use issue since adding an out of class definition fixes
the issue:

  constexpr double Blob::a ;

As far as I can tell a is not odr-used and so this should be valid code without
the out of class definition.

Note, using qualified id to access the member works though:

  auto c = Blob::a;

Also, using any level of optimization(-O1 etc...) also makes the problem go
away.

-- 
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/20150212/ad4c8df9/attachment.html>


More information about the llvm-bugs mailing list