<html>
<head>
<base href="http://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Compiler crash"
href="http://bugs.llvm.org/show_bug.cgi?id=32416">32416</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Compiler crash
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>-New Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>rbultje@twoorioles.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>(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
<a href="http://developer.apple.com/bugreporter/">http://developer.apple.com/bugreporter/</a> 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:
********************</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>