[llvm-bugs] [Bug 49263] New: clang: accept-invalid ill-formed C program / assertion `getLangOpts().CPlusPlus && "Call sites of this function should be guarded by checking for C++"'
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Feb 19 05:27:07 PST 2021
https://bugs.llvm.org/show_bug.cgi?id=49263
Bug ID: 49263
Summary: clang: accept-invalid ill-formed C program / assertion
`getLangOpts().CPlusPlus && "Call sites of this
function should be guarded by checking for C++"'
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: zhan3299 at purdue.edu
CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
neeilans at live.com, richard-llvm at metafoo.co.uk
Clang accepts this presumably-invalid code, which GCC rejects. It affects 11.0,
12.0, and trunk.
clang: https://godbolt.org/z/b7oaxq
GCC: https://godbolt.org/z/1194qP
---
$ cat test.c
struct another_struct {
int my_int;
};
struct my_struct {
struct {
int volatile (*func_ptr)(int[] = <, struct another_struct);
};
};
int volatile func(int a[]) { return a[0]; }
int main() {
struct my_struct x = { .func_ptr = &func };
int y = 1;
return (*x.func_ptr)(&y);
}
$ ./clang -o /tmp/a.out -x c -std=c11 -pedantic -Wall test.c
# no any warning or error
---
I try to make the compilation as strict as possible, so I set "-std=c11
-pedantic -Wall". Actually, the standard does not matter.
--
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/20210219/95233e3b/attachment.html>
More information about the llvm-bugs
mailing list