https://bugs.llvm.org/show_bug.cgi?id=40602
Bug ID: 40602
Summary: clang allows static VLAs for C99
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: -New Bugs
Assignee: unassignedclangb...@nondot.org
Reporter: henric.karls...@ericsson.com
CC: htmldevelo...@gmail.com, llvm-bugs@lists.llvm.org,
neeil...@live.com, richard-l...@metafoo.co.uk
Created attachment 21434
--> https://bugs.llvm.org/attachment.cgi?id=21434&action=edit
example code
It seems like clang is at least not consistent with how VLAs are allowed, and I
think clang is a bit too permissive. A VLA should not be allowed as static
variable.
reproducer command:
clang -S -std=c99 vla_tst.c
Code below is the same as in attached file vla_tst.c
Consider the following:
const int xx = 1;
- gcc gives an error for arrx, and global VLAs sounds strange, but clang
accepts this, possibly because xx is known at compiletime? But is not a
"constant expression" so should still be a VLA.
int arrx[xx];
- here clang gives an error for arr2 but not arr1. gcc gives an error for the
garr typedef (and arr2).
typedef int garr[xx];
void fn0() {
typedef int larr[xx];
static garr arr1;
static larr arr2;
}
- clang accepts arr3, but a static storage should not be allowed for a VLA.
void fn1() {
const int a = 1;
static int arr3[a];
}
- Here arr4 correctly results in an error with clang. So a little confusing why
clang allows some cases but not all.
void fn2() {
const int a = 1;
typedef int at[a];
static at arr4;
}
With -Wpedantic you get warnings for these (from C++ extension? )
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs