Hi, When we set void in va_arg, it becomes Segmentation fault. This problem was confirmed on gcc-4.3, 4.4, 4.5 and 4.6. $ cat a.c #include <stdarg.h> void f(va_list ap) { va_arg(ap,void); } $ gcc -c a.c a.c: In function 'f': a.c:2: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See <file:///usr/share/doc/gcc-4.4/README.Bugs> for instructions. $gcc -v Using built-in specs. Target: sh4-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 4.4.6-2' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.4 --enable-shared --enable-multiarch --with-multiarch-defaults=sh4-linux-gnu --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --with-multilib-list=m4,m4-nofpu --with-cpu=sh4 --enable-checking=release --build=sh4-linux-gnu --host=sh4-linux-gnu --target=sh4-linux-gnu Thread model: posix gcc version 4.4.6 (Debian 4.4.6-2)
This is a target problem. The patch below will fix it. BTW, I'm not sure that it's an invalid use of void or not in C, though g++ treats it as invalid. * config/sh/sh.c (sh_gimplify_va_arg_expr): Don't call targetm.calls.must_pass_in_stack for void type. --- ORIG/trunk/gcc/config/sh/sh.c 2011-04-23 09:43:19.000000000 +0900 +++ trunk/gcc/config/sh/sh.c 2011-04-26 10:40:25.000000000 +0900 @@ -8062,9 +8062,14 @@ sh_gimplify_va_arg_expr (tree valist, tr HOST_WIDE_INT size, rsize; tree tmp, pptr_type_node; tree addr, lab_over = NULL, result = NULL; - int pass_by_ref = targetm.calls.must_pass_in_stack (TYPE_MODE (type), type); + bool pass_by_ref; tree eff_type; + if (!VOID_TYPE_P (type)) + pass_by_ref = targetm.calls.must_pass_in_stack (TYPE_MODE (type), type); + else + pass_by_ref = false; + if (pass_by_ref) type = build_pointer_type (type);
Hi, Thanks for your work. (In reply to comment #1) > This is a target problem. The patch below will fix it. I confirm fix on gcc-4.4, 4,5 and 4.6. Thanks! > BTW, I'm not sure that it's an invalid use of void or not in C, > though g++ treats it as invalid. Yes, I think too. I will ask upstream writing such code. Nobuhiro
Fixed on trunk.
Could you backport earch branches? If you need patch, I will create.
It isn't a regression, is it? My gcc-4.2 segfaults too for that testcase.