[llvm-bugs] [Bug 32416] New: Compiler crash
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Mar 24 16:22:37 PDT 2017
http://bugs.llvm.org/show_bug.cgi?id=32416
Bug ID: 32416
Summary: Compiler crash
Product: clang
Version: unspecified
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: rbultje at twoorioles.com
CC: llvm-bugs at lists.llvm.org
(I originally filed this in Apple's bug reporting system as 31009924, but I'm
not getting any response there, so I figured I would post it here instead. If
this is the wrong place, I'm sorry.)
Using the provided source file, the compiler (Apple LLVM version 8.0.0
(clang-800.0.42.1)) crashes.
Please note that I'm fully aware that the provided code is not meaningful, it's
just a very condensed version of the actual source file that causes the
compiler crash.
Steps to Reproduce:
$ cat /tmp/test.c
#include <assert.h>
#include <stddef.h>
#include <stdlib.h>
typedef struct typeA { int placeholder; } typeA;
typedef struct typeB { int placeholder; typeA *a; } typeB;
typedef struct typeC { typeB *b; } typeC;
typedef struct typeD { int placeholder; typeC z[2]; } typeD;
typedef struct typeE { typeB *b; typeA *a; } typeE;
static void init2(typeE *const s, typeB *const b) { b->a = s->a; }
#define NUM_BYTES (sizeof(typeB) * 2 * 2)
static void init1(typeD *const t, uint8_t *const mem_in, const ptrdiff_t sz)
{
uint8_t *mem = mem_in;
typeE s;
uint8_t *ptrs[2], **ptr = ptrs;
*ptr = mem; mem += NUM_BYTES;
s.b = (typeB *) *ptr++;
*ptr = mem;
s.a = NULL;
int b, e;
for (b = 0; b < 2; b++) {
t->z[b].b = s.b;
for (e = 0; e < 2; e++)
init2(&s, &t->z[b].b[e]);
s.b += 2;
}
ptr = &ptrs[1];
assert(*ptr++ == (uint8_t *) s.b);
}
int main(void) {
const ptrdiff_t sz = NUM_BYTES;
uint8_t *const mem = malloc(sz);
init1(NULL, mem, sz);
return 0;
}
$ gcc -o /tmp/test.o -c /tmp/test.c -O3
clang: error: unable to execute command: Segmentation fault: 11
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
Apple LLVM version 8.0.0 (clang-800.0.42.1)
Target: x86_64-apple-darwin16.4.0
Thread model: posix
InstalledDir:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
clang: note: diagnostic msg: PLEASE submit a bug report to
http://developer.apple.com/bugreporter/ and include the crash backtrace,
preprocessed source, and associated run script.
clang: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg:
/var/folders/fz/vjyfg5z12vj759mhd1t27r_m0000gn/T/test-287e75.c
clang: note: diagnostic msg:
/var/folders/fz/vjyfg5z12vj759mhd1t27r_m0000gn/T/test-287e75.sh
clang: note: diagnostic msg:
********************
--
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/20170324/4cad3b9c/attachment-0001.html>
More information about the llvm-bugs
mailing list