[llvm-bugs] [Bug 39746] New: Crash - reinterpret_cast<> from forward declared class followed by array access
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Nov 21 15:23:55 PST 2018
https://bugs.llvm.org/show_bug.cgi?id=39746
Bug ID: 39746
Summary: Crash - reinterpret_cast<> from forward declared class
followed by array access
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: kobalicek.petr at gmail.com
CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
neeilans at live.com, richard-llvm at metafoo.co.uk
Sample code, compiled by clang 7 and trunk:
struct Something;
extern Something xxx[32];
class C {
public:
void* p;
};
const C& f() noexcept {
return reinterpret_cast<const C*>(xxx)[16];
}
Compiler explorer reproducible:
https://godbolt.org/#g:!((g:!((g:!((h:codeEditor,i:(j:1,lang:c%2B%2B,source:'%0Astruct+Something%3B%0A%0Aextern+Something+xxx%5B32%5D%3B%0A%0Aclass+C+%7B%0Apublic:%0A++void*+p%3B%0A%7D%3B%0A%0Aconst+C%26+f()+noexcept+%7B%0A++return+reinterpret_cast%3Cconst+C*%3E(xxx)%5B16%5D%3B%0A%7D'),l:'5',n:'0',o:'C%2B%2B+source+%231',t:'0')),k:50,l:'4',n:'0',o:'',s:0,t:'0'),(g:!((h:compiler,i:(compiler:clang_trunk,filters:(b:'0',binary:'1',commentOnly:'0',demangle:'0',directives:'0',execute:'1',intel:'0',trim:'1'),lang:c%2B%2B,libs:!(),options:'-O3',source:1),l:'5',n:'0',o:'x86-64+clang+(trunk)+(Editor+%231,+Compiler+%231)+C%2B%2B',t:'0')),k:50,l:'4',n:'0',o:'',s:0,t:'0')),l:'2',n:'0',o:'',t:'0')),version:4
--
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/20181121/b364c4ec/attachment-0001.html>
More information about the llvm-bugs
mailing list