[llvm-bugs] [Bug 35881] New: Unable to initialize/assign a pointer to VLA
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Jan 9 15:10:37 PST 2018
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: unassignedclangbugs at nondot.org
Reporter: ignat.loskutov at gmail.com
CC: dgregor at apple.com, llvm-bugs at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180109/c5d47df9/attachment.html>
More information about the llvm-bugs
mailing list