This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/31077] New: C handling of always_inline attribute error and a solution
- From: "zhouyi04 at ios dot cn" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 8 Mar 2007 09:37:19 -0000
- Subject: [Bug c/31077] New: C handling of always_inline attribute error and a solution
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
gcc will segment fault when compiling following code (copied from linux kernel)
when no optimize option is given (I need to debug linux kernel without
optimizing interfere my investigation):
gcc -S -i hello1.i
//hello1.i
1
2 struct genapic {
3
4 int (*check_phys_apicid_present)(int boot_cpu_physical_apicid);
5
6 unsigned (*get_apic_id)(unsigned long x);
7
8 };
9
10 static inline __attribute__((always_inline)) unsigned
get_apic_id(unsigned long x)
11 {
12 return 1;
13 }
14
15
16
17 static inline int check_phys_apicid_present(int cpu_physical_apicid)
18 {
19
20 return get_apic_id(2);
21
22 }
23
24
25 struct genapic apic_es7000 = { .check_phys_apicid_present =
check_phys_apicid_present,.get_ apic_id = get_apic_id, };
A solution is change gcc-4.1.0's function cgraph_preserve_function_body_p:
1201 bool
1202 cgraph_preserve_function_body_p (tree decl)
1203 {
1204 struct cgraph_node *node;
1205 /* Keep the body; we're going to dump it. */
1206 if (dump_enabled_p (TDI_tree_all))
1207 return true;
1208 if (!cgraph_global_info_ready)
1209 return (DECL_INLINE (decl) && !flag_really_no_inline);
1210 /* Look if there is any clone around. */
1211 for (node = cgraph_node (decl); node; node = node->next_clone)
1212 if (node->global.inlined_to)
1213 return true;
1214 return false;
1215 }
into
bool
cgraph_preserve_function_body_p (tree decl)
{
struct cgraph_node *node;
/* Keep the body; we're going to dump it. */
if (dump_enabled_p (TDI_tree_all))
return true;
if (!cgraph_global_info_ready && !((DECL_INLINE (decl) &&
!flag_really_no_inline))){
for (node = cgraph_node (decl); node; node = node->next_clone)
if (node->global.local.disregard_inline_limits)
return true;
return false;
}
/* Look if there is any clone around. */
for (node = cgraph_node (decl); node; node = node->next_clone)
if (node->global.inlined_to)
return true;
return false;
}
best regards
Zhouyi Zhou
--
Summary: C handling of always_inline attribute error and a
solution
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: zhouyi04 at ios dot cn
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31077