<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - static constexpr floating member incorrectly identified as odr-used"
   href="http://llvm.org/bugs/show_bug.cgi?id=22565">22565</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>static constexpr floating member incorrectly identified as odr-used
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++11
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>yaghmour.shafik@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Given the following code from stackoverflow question
<a href="http://stackoverflow.com/q/28264279/1708801">http://stackoverflow.com/q/28264279/1708801</a> :

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:

  <a href="http://melpon.org/wandbox/permlink/JRphxTSHekwqEd6p">http://melpon.org/wandbox/permlink/JRphxTSHekwqEd6p</a>

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.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>