[LLVMbugs] [Bug 22492] New: Range-for rejects constexpr on loop variable
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Fri Feb 6 09:37:00 PST 2015
http://llvm.org/bugs/show_bug.cgi?id=22492
Bug ID: 22492
Summary: Range-for rejects constexpr on loop variable
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.5.4 [stmt.ranged]/2, constexpr is explicitly
allowed in the decl-specifier-seq of a for-range-declaration.
For the source below, Clang produces an error; GCC compiles it fine.
### SOURCE (<stdin>):
struct Range {
struct It { operator int &(); int val; };
It begin();
It end();
} range;
constexpr int operator*(const Range::It &) { return 0; }
int main() {
for (constexpr int x : range) { }
}
### COMPILER INVOCATION:
clang -cc1 -std=c++11 -x c++ -
### ACTUAL OUTPUT:
<stdin>:10:9: error: loop variable 'x' may not be declared 'constexpr'
for (constexpr int x : range) { }
^
1 error 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/b8700be4/attachment.html>
More information about the llvm-bugs
mailing list