https://bugs.llvm.org/show_bug.cgi?id=35881
Bug ID: 35881
Summary: Unable to initialize/assign a pointer to VLA
Product: clang
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: C++
Assignee: unassignedclangb...@nondot.org
Reporter: ignat.losku...@gmail.com
CC: dgre...@apple.com, llvm-bugs@lists.llvm.org
Consider the following example:
int foo(int *ptr, size_t rows, size_t cols) {
int (*m)[cols] = (int(*)[cols])(ptr);
return m[rows - 1][cols - 1];
}
It fails to compile in C++ mode with a weird error message:
1 : <source>:1:11: error: cannot initialize a variable of type 'int (*)[cols]'
with an rvalue of type 'int (*)[cols]'
int (*ptr)[cols] = (int(*)[cols])(m);
^ ~~~~~~~~~~~~~~~~~
Although VLAs are not a part of C++ standard, Clang claims to support them for
compatibility with GCC. GCC, ICC, and Clang in C mode compile this piece of
code successfully.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs