[LLVMbugs] [Bug 4390] New: clang: wrong struct initializer
bugzilla-daemon at cs.uiuc.edu
bugzilla-daemon at cs.uiuc.edu
Sun Jun 14 03:57:11 PDT 2009
http://llvm.org/bugs/show_bug.cgi?id=4390
Summary: clang: wrong struct initializer
Product: new-bugs
Version: unspecified
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P2
Component: new bugs
AssignedTo: unassignedbugs at nondot.org
ReportedBy: edwintorok at gmail.com
CC: llvmbugs at cs.uiuc.edu
Blocks: 4068
clang creates this initializer for a struct:
@sysfs_root = global %0 <{ %struct.anon <{ i32 1 }>, %struct.anon
zeroinitializer, %struct.sysfs_dirent* null, %struct.sysfs_dirent* null, i8*
getelementptr ([1 x i8]* @.str, i32 0, i32 0), %union.anon zeroinitializer,
%union.anon zeroinitializer, i8 0, i8 0, i8 0, i8 0, i32 1, i64 1, i8 0, i8 0,
i8 0, i8 0, i8 0, i8 0, i16 16877 }>, align 8 ; <%0*> [#uses=1]
While llvm-gcc creates this initializer for same struct:
@sysfs_root = global %0 { %struct.atomic_t { i32 1 }, [20 x i8]
zeroinitializer, i8* getelementptr ([1 x i8]* @.str, i32 0, i32 0), [16 x i8]
zeroinitializer, i32 1, i64 1, i16 16877, [14 x i8] zeroinitializer }, align 32
; <%0*> [#uses=1]
This causes a panic when trying to boot the linux kernel compiled with clang.
Testcase below, when run with clang it aborts, when run
with llvm-gcc or gcc it doesn't:
struct hlist_node {
struct hlist_node *next, **pprev;
};
struct hlist_head {
struct hlist_node *first;
};
typedef unsigned short umode_t;
typedef unsigned long __kernel_ino_t;
typedef __kernel_ino_t ino_t;
struct sysfs_elem_dir {
struct kobject *kobj;
struct sysfs_dirent *children;
};
struct sysfs_elem_bin_attr {
struct bin_attribute *bin_attr;
struct hlist_head buffers;
};
typedef struct {
volatile int counter;
} atomic_t;
struct sysfs_elem_attr {
struct attribute *attr;
struct sysfs_open_dirent *open;
};
struct sysfs_elem_symlink {
struct sysfs_dirent *target_sd;
};
struct sysfs_dirent {
atomic_t s_count;
atomic_t s_active;
struct sysfs_dirent *s_parent;
struct sysfs_dirent *s_sibling;
const char *s_name;
union {
struct sysfs_elem_dir s_dir;
struct sysfs_elem_symlink s_symlink;
struct sysfs_elem_attr s_attr;
struct sysfs_elem_bin_attr s_bin_attr;
};
unsigned int s_flags;
ino_t s_ino;
umode_t s_mode;
struct iattr *s_iattr;
};
struct sysfs_dirent sysfs_root = {
.s_name = "",
.s_count = { (1) },
.s_flags = 0x0001,
.s_mode = 0040000 | 00700 | (00400|00040|00004) | (00100|00010|00001),
.s_ino = 1,
};
struct iattr *foo()
{
return sysfs_root.s_iattr;
}
umode_t bar()
{
return sysfs_root.s_mode;
}
int main()
{
if (foo() || bar() != 16877)
abort();
}
--
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