[Bug middle-end/53790] New: ICE on dereferencing a extern union in asm statement
samueldotj at gmail dot com
gcc-bugzilla@gcc.gnu.org
Wed Jun 27 21:17:00 GMT 2012
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53790
Bug #: 53790
Summary: ICE on dereferencing a extern union in asm statement
Classification: Unclassified
Product: gcc
Version: 4.6.3
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: middle-end
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: samueldotj@gmail.com
Created attachment 27713
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27713
Preprocessed sources
gcc-4.6.3 causes ICE when compiling program which dereferences a extern union
in asm().
It is avoided if the union's structure is made known to the compiler at compile
time.(Defined inside the c file or in an include file).
Removing optimization(-O0) also avoid this problem.
------------------------------
typedef long long uint64;
typedef struct s {
uint64 value;
} s_t;
static inline uint64
do_some_asm(s_t const *var)
{
uint64 value;
__asm__ __volatile__(
"xor %1, %0"
: "=r" (value)
: "r" (var->value)
);
return value;
}
typedef union u u_t;
int main()
{
extern u_t extern_var;
return do_some_asm((s_t *)&extern_var);
}
----------------------------
$gcc -v -save-temps -O3 sample.c
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.6.3/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ./configure
Thread model: posix
gcc version 4.6.3 (GCC)
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-O3' '-mtune=generic' '-march=x86-64'
/usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.6.3/cc1 -E -quiet -v
sample.c -mtune=generic -march=x86-64 -O3 -fpch-preprocess -o sample.i
ignoring nonexistent directory
"/usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../x86_64-unknown-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/include
/usr/local/include
/usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/include-fixed
/usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-O3' '-mtune=generic' '-march=x86-64'
/usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.6.3/cc1 -fpreprocessed
sample.i -quiet -dumpbase sample.c -mtune=generic -march=x86-64 -auxbase sample
-O3 -version -o sample.s
GNU C (GCC) version 4.6.3 (x86_64-unknown-linux-gnu)
compiled by GNU C version 4.6.3, GMP version 4.3.2, MPFR version
2.4.2-p1, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU C (GCC) version 4.6.3 (x86_64-unknown-linux-gnu)
compiled by GNU C version 4.6.3, GMP version 4.3.2, MPFR version
2.4.2-p1, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 4cf08a0fcb4b2719a02f394936c437ef
sample.c: In function ‘main’:
sample.c:15:17: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
Currently I am working around this by applying the following patch.
diff -rupN gcc-4.6.3/gcc/expr.c gcc-4.6.3.new1/gcc/expr.c
--- gcc-4.6.3/gcc/expr.c 2012-02-09 09:28:22.000000000 -0800
+++ gcc-4.6.3.new1/gcc/expr.c 2012-06-20 22:53:10.613748645 -0700
@@ -9182,6 +9182,7 @@ expand_expr_real_1 (tree exp, rtx target
orig_op0 = op0
= expand_expr (tem,
(TREE_CODE (TREE_TYPE (tem)) == UNION_TYPE
+ && TYPE_SIZE (TREE_TYPE (tem))
&& (TREE_CODE (TYPE_SIZE (TREE_TYPE (tem)))
!= INTEGER_CST)
&& modifier != EXPAND_STACK_PARM
More information about the Gcc-bugs
mailing list