[LLVMbugs] [Bug 12630] New: clang dumps core on struct initialiser

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Apr 23 05:44:57 PDT 2012


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

             Bug #: 12630
           Summary: clang dumps core on struct initialiser
           Product: new-bugs
           Version: 3.0
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: devel at fresse.org
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


shell> /usr/bin/clang --version         
SUSE Linux clang version 3.0 (branches/release_30 145598) (based on LLVM 3.0)
Target: x86_64-unknown-linux-gnu
Thread model: posix

shell> /usr/bin/clang -v -std=c99 test.c
SUSE Linux clang version 3.0 (branches/release_30 145598) (based on LLVM 3.0)
Target: x86_64-unknown-linux-gnu
Thread model: posix
 "/usr/bin/clang-3.0" -cc1 -triple x86_64-unknown-linux-gnu -emit-obj
-mrelax-all -disable-free -disable-llvm-verifier -main-file-name test.c
-mrelocation-model static -mdisable-fp-elim -masm-verbose -mconstructor-aliases
-munwind-tables -target-cpu x86-64 -momit-leaf-frame-pointer -v -resource-dir
/usr/bin/../lib64/clang/3.0 -fmodule-cache-path /var/tmp/clang-module-cache
-internal-isystem /usr/local/include -internal-isystem
/usr/bin/../lib64/clang/3.0/include -internal-externc-isystem /usr/include
-std=c99 -ferror-limit 19 -fmessage-length 210 -fgnu-runtime
-fobjc-runtime-has-arc -fobjc-runtime-has-weak -fobjc-fragile-abi
-fdiagnostics-show-option -fcolor-diagnostics -o /tmp/test-uwuJDX.o -x c test.c
clang -cc1 version 3.0 based upon llvm 3.0 hosted on x86_64-unknown-linux-gnu
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/bin/../lib64/clang/3.0/include
 /usr/include
End of search list.
test.c:49:8: warning: subobject initialization overrides initialization of
other fields within its enclosing subobject [-Winitializer-overrides]
                .t = {
                     ^
test.c:45:15: note: previous initialization is here
                .sandwich = 0U,
                            ^~
Stack dump:
0.      Program arguments: /usr/bin/clang-3.0 -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free
-disable-llvm-verifier -main-file-name test.c -mrelocation-model static
-mdisable-fp-elim -masm-verbose -mconstructor-aliases -munwind-tables
-target-cpu x86-64 -momit-leaf-frame-pointer -v -resource-dir
/usr/bin/../lib64/clang/3.0 -fmodule-cache-path /var/tmp/clang-module-cache
-internal-isystem /usr/local/include -internal-isystem
/usr/bin/../lib64/clang/3.0/include -internal-externc-isystem /usr/include
-std=c99 -ferror-limit 19 -fmessage-length 210 -fgnu-runtime
-fobjc-runtime-has-arc -fobjc-runtime-has-weak -fobjc-fragile-abi
-fdiagnostics-show-option -fcolor-diagnostics -o /tmp/test-uwuJDX.o -x c test.c 
1.      <eof> parser at end of file
2.      Per-file LLVM IR generation
3.      test.c:41:1: Generating code for declaration 'dt_dt_initialiser'
4.      test.c:42:1: LLVM IR generation of compound statement ('{}')
clang-3: error: unable to execute command: Segmentation fault (core dumped)
clang-3: error: clang frontend command failed due to signal 2 (use -v to see
invocation)
clang-3: note: diagnostic msg: Please submit a bug report to  and include
command line arguments and all diagnostic information.
clang-3: note: diagnostic msg: Preprocessed source(s) are located at:
clang-3: note: diagnostic msg: /tmp/test-JAsF6K.i


shell> cat test.c
#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 struct dt_dt_s
__attribute__((pure, const))
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;
}

-- 
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