[LLVMbugs] [Bug 15651] New: Clang fails to build a template that uses constexpr.

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Apr 1 22:43:12 PDT 2013


            Bug ID: 15651
           Summary: Clang fails to build a template that uses constexpr.
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: jujjyl at gmail.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 10275
  --> http://llvm.org/bugs/attachment.cgi?id=10275&action=edit
-E -generated test case.

I have built Clang 3.2 on Windows following these instructions:
(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
https://github.com/kripken/emscripten/wiki/Getting-started-on-Mac-OS-X and
https://github.com/kripken/emscripten/wiki/Getting-Started-on-Ubuntu-12.10 )

A large test case is available at

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__
-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++'

error: constexpr variable 'ts_sec_max' must be initialized by a constant
 _LIBCPP_CONSTEXPR ts_sec ts_sec_max = numeric_limits::max();
 ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

note: undefined function 'max' cannot be used in a constant expression
 _LIBCPP_CONSTEXPR ts_sec ts_sec_max = numeric_limits::max();

note: declared here
{return __base::max();}
 1 error generated.

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

The same problem is tracked in the emscripten issue tracker here:

I also tried with the Clang trunk on Windows, which also fails in the same way:

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?

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/20130402/e59557c0/attachment.html>

More information about the llvm-bugs mailing list