[llvm-bugs] [Bug 32416] Compiler crash
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Mar 29 14:57:58 PDT 2017
http://bugs.llvm.org/show_bug.cgi?id=32416
rbultje at twoorioles.com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Resolution|INVALID |---
--- Comment #4 from rbultje at twoorioles.com ---
Hey guys,
I'm really terribly sorry to reopen this bug. Let me explain: Apple just
released XCode 8.3 (with their "clang 8.1") and it fixed the compiler crash.
However, the compiler (still?) miscompiles the code. What's more interesting is
that the miscompilation reproduces in upstream clang! I'm hoping this time the
bug report is acceptable.
(Below, "clang-mp-4.0" is clang-4.0 installed from MacPorts, and gcc-mp-4.8 is
gcc-4.8 installed from MacPorts.)
===
$ clang-mp-4.0 --version
clang version 4.0.0 (branches/release_40 292772)
Target: x86_64-apple-darwin16.4.0
Thread model: posix
InstalledDir: /opt/local/libexec/llvm-4.0/bin
$ cat /tmp/x.c
#include <assert.h>
#include <stddef.h>
#include <stdlib.h>
#include <stdio.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];
ptrs[0] = mem; mem += NUM_BYTES;
s.b = (typeB *) ptrs[0];
ptrs[1] = 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;
}
printf("assert(%p == %p);\n", ptrs[1], s.b);
assert(ptrs[1] == (uint8_t *) s.b);
}
int main(void) {
const ptrdiff_t sz = NUM_BYTES;
typeD *d = malloc(sizeof(typeD));
uint8_t *const mem = malloc(sz);
init1(d, mem, sz);
return 0;
}
$ clang-mp-4.0 -o /tmp/x -O3 /tmp/x.c
$ /tmp/x
assert(0x7f84144028a0 == 0x7f84144028a0);
Assertion failed: (ptrs[1] == (uint8_t *) s.b), function init1, file /tmp/x.c,
line 34.
Abort trap: 6
$ gcc-mp-4.8 --version
gcc-mp-4.8 (MacPorts gcc48 4.8.5_0) 4.8.5
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ gcc-mp-4.8 -o /tmp/x -O3 /tmp/x.c
$ /tmp/x
assert(0x7f7f944028a0 == 0x7f7f944028a0);
--
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/20170329/0d8cae0a/attachment.html>
More information about the llvm-bugs
mailing list