[LLVMbugs] [Bug 20630] New: clang incorrectly infers that a fixed length array is a VLA when passing a const size through a function.
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Mon Aug 11 18:18:13 PDT 2014
http://llvm.org/bugs/show_bug.cgi?id=20630
Bug ID: 20630
Summary: clang incorrectly infers that a fixed length array is
a VLA when passing a const size through a function.
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: ian.forbes at mail.mcgill.ca
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
Classification: Unclassified
Clang allows C-style arrays of non-POD type but only when the size of these
array is known at compile time as per:
http://clang.llvm.org/compatibility.html#vla
However the following does not complile and complains that the array has a
variable length.
========================================
#include <vector>
void func(const int n)
{
std::vector<int> futs[n];
}
int main()
{
const int n = 5;
func(n);
}
========================================
works2.cpp:5:26: error: variable length array of non-POD element type
'std::vector<int>'
std::vector<int> futs[n];
^
1 error generated.
=========================================
This also happens when calling func with a literal.
The issue is that the size of the array is known at compile time but clang does
not know this unless the size is in the local scope of the function when the
array is being created.
This may not actually be a bug and may be the expected behaviour but if this is
the case the webpage should be updated to reflect this short comming.
Additional Info:
Ubuntu clang version 3.5-1ubuntu1 (trunk) (based on LLVM 3.5)
Target: x86_64-pc-linux-gnu
Thread model: posix
--
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/20140812/45258265/attachment.html>
More information about the llvm-bugs
mailing list