[LLVMbugs] [Bug 22491] New: "type name does not allow constexpr specifier to be specified" using constexpr in condition

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Feb 6 09:18:05 PST 2015


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

            Bug ID: 22491
           Summary: "type name does not allow constexpr specifier to be
                    specified" using constexpr in condition
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: hstong at ca.ibm.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

According to N3290 subclause 6.4 [stmt.select]/6, constexpr is explicitly
allowed in the decl-specifier-seq of a condition.
This applies to "if", "switch", "for" and "while" statements.

For the source below, Clang produces an error; GCC compiles it fine.

### SOURCE (<stdin>):
class Countdown {
public:
   constexpr Countdown(int bias) : bias(bias) { }
   operator int();
private:
   static int countdown;
   int bias;
};

int main() {
   if (constexpr Countdown c = 200) { }
   switch (constexpr Countdown c = 100) { }
   for (; constexpr Countdown c = 50; ) { }
   while (constexpr Countdown c = 25) { }
}


### COMPILER INVOCATION:
clang -cc1 -std=c++11 -x c++ -


### ACTUAL OUTPUT:
<stdin>:11:8: error: type name does not allow constexpr specifier to be
specified
   if (constexpr Countdown c = 200) { }
       ^
<stdin>:12:12: error: type name does not allow constexpr specifier to be
specified
   switch (constexpr Countdown c = 100) { }
           ^
<stdin>:13:11: error: type name does not allow constexpr specifier to be
specified
   for (; constexpr Countdown c = 50; ) { }
          ^
<stdin>:14:11: error: type name does not allow constexpr specifier to be
specified
   while (constexpr Countdown c = 25) { }
          ^
4 errors generated.


### EXPECTED OUTPUT:
Clean compile.


### COMPILER VERSION INFO:
clang version 3.7.0 (trunk 228401)
Target: x86_64-unknown-linux-gnu
Thread model: posix
Found candidate GCC installation:
/usr/local/gcc-4.8.2/lib/gcc/x86_64-unknown-linux-gnu/4.8.2
Selected GCC installation:
/usr/local/gcc-4.8.2/lib/gcc/x86_64-unknown-linux-gnu/4.8.2
Candidate multilib: .;@m64
Selected multilib: .;@m64

-- 
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/20150206/4e933285/attachment.html>


More information about the llvm-bugs mailing list