On Fri, 24 Aug 2007, Brian Sidebotham wrote:
> This ICE is caused by the following patch:
>
> 2007-08-10 Kaveh R. Ghazi <[EMAIL PROTECTED]>
>
> * system.h (CONST_CAST): New.
> * c-decl.c (c_make_fname_decl): Use it.
> * c-lex.c (cb_ident, lex_string): Likewise.
> * c-typeck.c (free_all_tagged_tu_seen_up_to): Likewise.
> * gcc.c (set_spec, read_specs, for_each_path, execute, do_spec_1,
> give_switch, set_multilib_dir): Likewise.
> * gengtype-parse.c (string_seq, typedef_name): Likewise.
> * passes.c (execute_one_pass): Likewise.
> * prefix.c (update_path): Likewise.
> * pretty-print.c (pp_base_destroy_prefix): Likewise.
> * tree.c (build_string): Likewise.
>
> Reverting this patch lets gcc build again.
>
> Unfortunately, CONST_CAST is a mystery to me (I don't understand it!) so there
> is no hope of me changing it to compile okay AND be right!
The definition of the CONST_CAST macro is syntactically correct, you don't
need to change it. The problem is that gcc-4.0.x has a bug exposed by
this expression. I reproduced it on sparc-sun-solaris2.10 with gcc-4.0.4.
I've many times succesfully bootstrapped GCC with other (older!) versions
(2.8.1, 3.4.6) so it's just random bad luck we ran into this now. I also
verified that your tree.i file compiles with 4.1.3 (prerelease) and 4.2.2
(prerelease). Mainline obviously works too or nobody could bootstrap.
So I believe the ICE is something confined to the 4.0.x series.
Does this work for you? If so, I'll install it as "obvious".
Thanks,
--Kaveh
2007-08-26 Kaveh R. Ghazi <[EMAIL PROTECTED]>
* system.h (CONST_CAST): Avoid union for gcc-4.0.x.
diff -rup orig/egcc-SVN20070825/gcc/system.h egcc-SVN20070825/gcc/system.h
--- orig/egcc-SVN20070825/gcc/system.h 2007-08-10 14:11:38.000000000 -0400
+++ egcc-SVN20070825/gcc/system.h 2007-08-26 12:29:12.577795974 -0400
@@ -774,7 +774,9 @@ extern void fancy_abort (const char *, i
execv, et al. Another valid use would be in an allocation function
that creates const objects that need to be initialized. Most other
cases should be viewed with extreme caution. */
-#ifdef __GNUC__
+
+#if defined(__GNUC__) && GCC_VERSION != 4000
+/* GCC 4.0.x has a bug where it may ICE on this expression. */
#define CONST_CAST(X) ((__extension__(union {__typeof(X)_q; void *_v;})(X))._v)
#else
#define CONST_CAST(X) ((void*)(X))