<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 --- - Clang fails to build a template that uses constexpr."
   href="http://llvm.org/bugs/show_bug.cgi?id=15651">15651</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Clang fails to build a template that uses constexpr.
          </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>Windows NT
          </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>jujjyl@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>Created <span class=""><a href="attachment.cgi?id=10275" name="attach_10275" title="-E -generated test case.">attachment 10275</a> <a href="attachment.cgi?id=10275&action=edit" title="-E -generated test case.">[details]</a></span>
-E -generated test case.

I have built Clang 3.2 on Windows following these instructions:
<a href="https://github.com/kripken/emscripten/wiki/Using-Emscripten-from-Visual-Studio-2010">https://github.com/kripken/emscripten/wiki/Using-Emscripten-from-Visual-Studio-2010</a>
(step 4 on that page)

Using that to build libcxx on Windows for emscripten, I am bit by an issue
where a constexpr inside a template class is not working.

The same code builds ok on Clang 3.2 built on Linux or OSX (following
instructions at
<a href="https://github.com/kripken/emscripten/wiki/Getting-started-on-Mac-OS-X">https://github.com/kripken/emscripten/wiki/Getting-started-on-Mac-OS-X</a> and
<a href="https://github.com/kripken/emscripten/wiki/Getting-Started-on-Ubuntu-12.10">https://github.com/kripken/emscripten/wiki/Getting-Started-on-Ubuntu-12.10</a> )

A large test case is available at
<a href="https://dl.dropbox.com/u/40949268/emcc/bugs/preprocessed.cpp">https://dl.dropbox.com/u/40949268/emcc/bugs/preprocessed.cpp</a> 

Compiling on Windows with "clang++ -std=c++11 -m32 -U__i386__ -U__x86_64__
-U__i386 -U__x86_64 -Ui386 -Ux86_64 -U__SSE__ -U__SSE2__ -U__MMX__
-UX87_DOUBLE_ROUNDING -UHAVE_GCC_ASM_FOR_X87 -DEMSCRIPTEN -U__STRICT_ANSI__
-U__CYGWIN__ -D__STDC__ -Xclang -triple=i386-pc-linux-gnu
-D__IEEE_LITTLE_ENDIAN -fno-math-errno -fno-ms-compatibility -nostdinc
-nostdinc++ -Xclang -nobuiltininc -Xclang -nostdsysteminc -U__APPLE__
-U__linux__ -emit-llvm -c preprocessed.cpp"

gives the error

clang++: warning: argument unused during compilation: '-nostdinc++'

G:\Inttel-slave\win-emcc-incoming-tests\build\system\lib\libcxx\condition_variable.cpp:59:30:
error: constexpr variable 'ts_sec_max' must be initialized by a constant
expression
 _LIBCPP_CONSTEXPR ts_sec ts_sec_max = numeric_limits::max();
 ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

G:\Inttel-slave\win-emcc-incoming-tests\build\system\lib\libcxx\condition_variable.cpp:59:43:
note: undefined function 'max' cannot be used in a constant expression
 _LIBCPP_CONSTEXPR ts_sec ts_sec_max = numeric_limits::max();
 ^

G:\Inttel-slave\win-emcc-incoming-tests\build\system\include\libcxx\limits:443:61:
note: declared here
 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type max() _NOEXCEPT
{return __base::max();}
 ^
 1 error generated.

A minimal failing example that exhibits the same problem is available at
<a href="https://dl.dropbox.com/u/40949268/emcc/bugs/constexpr_fail.cpp">https://dl.dropbox.com/u/40949268/emcc/bugs/constexpr_fail.cpp</a> which fails as
follows: <a href="https://dl.dropbox.com/u/40949268/emcc/bugs/constexpr_fail.txt">https://dl.dropbox.com/u/40949268/emcc/bugs/constexpr_fail.txt</a>

The same problem is tracked in the emscripten issue tracker here:
<a href="https://github.com/kripken/emscripten/issues/1019">https://github.com/kripken/emscripten/issues/1019</a>

I also tried with the Clang trunk on Windows, which also fails in the same way:
<a href="https://dl.dropbox.com/u/40949268/emcc/bugs/constexpr_fail_clang33trunk.txt">https://dl.dropbox.com/u/40949268/emcc/bugs/constexpr_fail_clang33trunk.txt</a>

Any ideas what could cause this kind of thing to work on linux and OSX builds
of Clang, but not on Windows builds of Clang?</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>