[LLVMbugs] [Bug 13327] clang dumps core when initialising a struct

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Jul 12 23:16:24 PDT 2012


http://llvm.org/bugs/show_bug.cgi?id=13327

Sebastian Freundt <devel at fresse.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|WORKSFORME                  |

--- Comment #3 from Sebastian Freundt <devel at fresse.org> 2012-07-13 01:16:24 CDT ---
No it doesn't.

freundt at clyde:pts/13:~/temp> clang --version
clang version 3.2 (trunk 160132)
Target: x86_64-unknown-linux-gnu
Thread model: posix

test.c
--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<-
#include <stdint.h>

struct dt_d_s {
        uint32_t u;
};

struct dt_t_s {
        uint32_t u;
};

struct dt_dt_s {
        union {
                /* packs */
                struct {
                        /* dt type, or date type */
                        uint16_t typ:4;
                        /* sandwich indicator (use d and t slots below) */
                        uint16_t sandwich:1;
                        /* unused, pad to next ui8 */
                        uint16_t:3;
                        /* duration indicator */
                        uint16_t dur:1;
                        /* negation indicator */
                        uint16_t neg:1;
                        /* pad to push the next 53 bits MSB-wards */
                        uint16_t:1;
                        union {
                                uint64_t u:53;
                        };
                } __attribute__((packed));
                /* sandwich types */
                struct {
                        struct dt_d_s d;
                        struct dt_t_s t;
                };
        };
};

static inline __attribute__((pure, const)) struct dt_dt_s
dt_dt_initialiser(void)
{
        struct dt_dt_s res = {
                .typ = 0,
                .sandwich = 0U,
                .dur = 0U,
                .neg = 0U,
                .u = 0U,
                .t = {
                        .u = 0,
                },
        };
        return res;
}

int
main(void)
{
        struct dt_dt_s res = dt_dt_initialiser();
        return res.sandwich;
}
--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<-


freundt at clyde:pts/13:~/temp> clang -v -std=c99 test.c
clang version 3.2 (trunk 160132)
Target: x86_64-unknown-linux-gnu
Thread model: posix
 "/home/freundt/usr/bin/clang" -cc1 -triple x86_64-unknown-linux-gnu -emit-obj
-mrelax-all -disable-free -main-file-name test.c -mrelocation-model static
-mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases
-munwind-tables -fuse-init-array -target-cpu x86-64 -target-linker-version
2.21.51.0.7.20110306 -momit-leaf-frame-pointer -v -resource-dir
/home/freundt/usr/bin/../lib/clang/3.2 -fmodule-cache-path
/tmp/clang-module-cache -internal-isystem /usr/local/include -internal-isystem
/home/freundt/usr/bin/../lib/clang/3.2/include -internal-externc-isystem
/include -internal-externc-isystem /usr/include -std=c99
-fdebug-compilation-dir /home/freundt/temp -ferror-limit 19 -fmessage-length
210 -mstackrealign -fobjc-runtime=gcc -fdiagnostics-show-option
-fcolor-diagnostics -o /tmp/test-0g7BmK.o -x c test.c
clang -cc1 version 3.2 based upon LLVM 3.2svn default target
x86_64-unknown-linux-gnu
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /home/freundt/usr/bin/../lib/clang/3.2/include
 /usr/include
End of search list.
test.c:48:22: warning: subobject initialization overrides initialization of
other fields within its enclosing subobject [-Winitializer-overrides]
                .t = {
                     ^
test.c:44:29: note: previous initialization is here
                .sandwich = 0U,
                            ^~
clang: /var/scratch/freundt/src/devel/llvm/include/llvm/Support/Casting.h:194:
typename cast_retty<ConstantInt, Constant *>::ret_type
llvm::cast(llvm::Constant *const &): Assertion `isa<X>(Val) && "cast<Ty>()
argument of incompatible type!"' failed.
0  clang           0x0000000002b6193e
1  clang           0x0000000002b61e3a
2  libpthread.so.0 0x00007f615c0e42d0
3  libc.so.6       0x00007f615b423ab5 gsignal + 53
4  libc.so.6       0x00007f615b424fb6 abort + 390
5  libc.so.6       0x00007f615b41c385 __assert_fail + 245
6  clang           0x0000000000afff16 llvm::cast_retty<llvm::ConstantInt,
llvm::Constant*>::ret_type llvm::cast<llvm::ConstantInt,
llvm::Constant*>(llvm::Constant* const&) + 70
7  clang           0x0000000000bc170b
8  clang           0x0000000000bc1385
9  clang           0x0000000000bc1304
10 clang           0x0000000000bc00d4
11 clang           0x0000000000bbba4e
12 clang           0x0000000000bbc4de
clang::CodeGen::CodeGenModule::EmitConstantExpr(clang::Expr const*,
clang::QualType, clang::CodeGen::CodeGenFunction*) + 286
13 clang           0x0000000000bc1637
14 clang           0x0000000000bc1385
15 clang           0x0000000000bc1304
16 clang           0x0000000000bc00d4
17 clang           0x0000000000bbba4e
18 clang           0x0000000000bbc4de
clang::CodeGen::CodeGenModule::EmitConstantExpr(clang::Expr const*,
clang::QualType, clang::CodeGen::CodeGenFunction*) + 286
19 clang           0x0000000000bc1637
20 clang           0x0000000000bc1385
21 clang           0x0000000000bc1304
22 clang           0x0000000000bc00d4
23 clang           0x0000000000bbba4e
24 clang           0x0000000000bbabab
clang::CodeGen::CodeGenModule::EmitConstantInit(clang::VarDecl const&,
clang::CodeGen::CodeGenFunction*) + 283
25 clang           0x0000000000b69796
clang::CodeGen::CodeGenFunction::EmitAutoVarInit(clang::CodeGen::CodeGenFunction::AutoVarEmission
const&) + 502
26 clang           0x0000000000b67225
clang::CodeGen::CodeGenFunction::EmitAutoVarDecl(clang::VarDecl const&) + 53
27 clang           0x0000000000b670f1
clang::CodeGen::CodeGenFunction::EmitVarDecl(clang::VarDecl const&) + 81
28 clang           0x0000000000b66f65
clang::CodeGen::CodeGenFunction::EmitDecl(clang::Decl const&) + 181
29 clang           0x0000000000c47205
clang::CodeGen::CodeGenFunction::EmitDeclStmt(clang::DeclStmt const&) + 117
30 clang           0x0000000000c428f7
clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*) + 295
31 clang           0x0000000000c42227
clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*) + 87
32 clang           0x0000000000c47011
clang::CodeGen::CodeGenFunction::EmitCompoundStmt(clang::CompoundStmt const&,
bool, clang::CodeGen::AggValueSlot) + 257
33 clang           0x0000000000c428d5
clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*) + 261
34 clang           0x0000000000c42227
clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*) + 87
35 clang           0x0000000000c5f8ee
clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::CodeGen::FunctionArgList&)
+ 142
36 clang           0x0000000000c5fd36
clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl,
llvm::Function*, clang::CodeGen::CGFunctionInfo const&) + 1078
37 clang           0x0000000000a976b6
clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl)
+ 822
38 clang           0x0000000000a95382
clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl) + 498
39 clang           0x0000000000a929c2
clang::CodeGen::CodeGenModule::EmitDeferred() + 434
40 clang           0x0000000000a926b9 clang::CodeGen::CodeGenModule::Release()
+ 25
41 clang           0x0000000000a8e008
42 clang           0x0000000000a8c08f
43 clang           0x0000000000c8baf2 clang::ParseAST(clang::Sema&, bool, bool)
+ 786
44 clang           0x00000000008a04a8 clang::ASTFrontendAction::ExecuteAction()
+ 312
45 clang           0x0000000000a8b61b clang::CodeGenAction::ExecuteAction() +
1259
46 clang           0x00000000008a00bb clang::FrontendAction::Execute() + 235
47 clang           0x0000000000873598
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 776
48 clang           0x000000000083a0f1
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 961
49 clang           0x00000000008249d9 cc1_main(char const**, char const**, char
const*, void*) + 969
50 clang           0x0000000000833f2d main + 477
51 libc.so.6       0x00007f615b40fbfd __libc_start_main + 253
52 clang           0x0000000000824529
Stack dump:
0.    Program arguments: /home/freundt/usr/bin/clang -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name
test.c -mrelocation-model static -mdisable-fp-elim -fmath-errno -masm-verbose
-mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64
-target-linker-version 2.21.51.0.7.20110306 -momit-leaf-frame-pointer -v
-resource-dir /home/freundt/usr/bin/../lib/clang/3.2 -fmodule-cache-path
/tmp/clang-module-cache -internal-isystem /usr/local/include -internal-isystem
/home/freundt/usr/bin/../lib/clang/3.2/include -internal-externc-isystem
/include -internal-externc-isystem /usr/include -std=c99
-fdebug-compilation-dir /home/freundt/temp -ferror-limit 19 -fmessage-length
210 -mstackrealign -fobjc-runtime=gcc -fdiagnostics-show-option
-fcolor-diagnostics -o /tmp/test-0g7BmK.o -x c test.c 
1.    <eof> parser at end of file
2.    Per-file LLVM IR generation
3.    test.c:40:1: Generating code for declaration 'dt_dt_initialiser'
4.    test.c:41:1: LLVM IR generation of compound statement ('{}')
clang: error: unable to execute command: Aborted (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.2 (trunk 160132)
Target: x86_64-unknown-linux-gnu
Thread model: posix
clang: note: diagnostic msg: PLEASE submit a bug report to
http://llvm.org/bugs/ 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: /tmp/test-DRetMV.c
clang: note: diagnostic msg: /tmp/test-DRetMV.sh
clang: note: diagnostic msg: 

********************

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list