2.95.2 GNU/Linux ICE on (namespace scope) static int arithmetic
Jonathan Thornburg
jthorn@davinci.thp.univie.ac.at
Tue Feb 29 09:18:00 GMT 2000
This is a bug report for gcc 2.95.2 on a Red Hat GNU/Linux 6.0 system.
In messages <199911211542.QAA29833@mach.thp.univie.ac.at> (21 Nov 1999)
and <200001142005.VAA11286@davinci.thp.univie.ac.at> (14 Jan 2000), I
(Jonathan Thornburg <jthorn@galileo.thp.univie.ac.at>) reported that
> gcc 2.95.2 gives an internal
> compiler error on the C++ source code line
>
> assert(! fuzzy<fp>::EQ(fabs( mu_bar), 0.5*PI));
>
> where bool fuzzy<fp>::EQ(fp, fp) is a template function, fp is
> a typedef for double , and PI is #defined to 3.14159... :
>
[[...]]
>
> Interestingly, on a SunOS 4.1.3 sparc v7 system, gcc 2.95.2 does *not*
> give an internal compiler error on this same code (that is, *my* code
> is the same; the system header files are of course now gcc's fixed versions
> of the SunOS ones instead of the GNU/Linux ones). This might due to a
> platform-dependent #ifdef in my code, but I suspect it's more likely due
> to a different assert() macro.
In trying to figure out a workaround for the GNU/Linux system, I have
now discovered that the problem is a bit more complicated than I'd
thought. gcc 2.95.2 on the GNU/Linux system still reports an ICE on
the above source line (I'm using a slightly different version of the
source files, so the line numbers have changed),
% /usr/local/share2/bin/g++ -fsyntax-only -nostdlib -pipe -ffast-math -D__USE_FIXED_PROTOTYPES__ -Wall -W -Wno-unused -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Woverloaded-virtual -Wsynth -ffor-scope -I/usr/local/lib -I/home/jthorn -L/home/jthorn/lib.i686 coords.cc
coords.cc:326: Internal compiler error.
coords.cc:326: Please submit a full bug report.
coords.cc:326: See <URL: http://www.gnu.org/software/gcc/faq.html#bugreport > for instructions.
The ICE (which I'll call bug #1) is reported in the line of the first
assert() in this compilation unit
324 fp coords::phi_of_mu_nu(fp mu, fp nu)
325 {
326 assert(! fuzzy<fp>::EQ(fabs(mu), 0.5*PI));
327 assert(! fuzzy<fp>::EQ(fabs(nu), 0.5*PI));
328
329 fp y_over_z = tan(mu);
330 fp x_over_z = tan(nu);
331 return jtutil::arctan_xy(x_over_z, y_over_z);
332 }
where fp is a typedef for double.
*But*, I have now found that disabling assert() (-DNDEBUG) produces a
quite different ICE (which I'll call bug #2) (again, this is all for the
GNU/Linux system, gcc has no problems with this code on the SunOS system):
% /usr/local/share2/bin/g++ -fsyntax-only -nostdlib -pipe -ffast-math -D__USE_FIXED_PROTOTYPES__ -Wall -W -Wno-unused -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Woverloaded-virtual -Wsynth -ffor-scope -I/usr/local/lib -I/home/jthorn -L/home/jthorn/lib.i686 -DNDEBUG coords.cc
coords.hh:236: Internal compiler error.
coords.hh:236: Please submit a full bug report.
coords.hh:236: See <URL: http://www.gnu.org/software/gcc/faq.html#bugreport > for instructions.
%
This time the offending code (with line numbers) is
217 namespace mu_nu_phi
218 {
219 static const int N_coords = 3;
220
221 // tensor indices
222 static const int index_mu = 0;
223 static const int index_nu = 1;
224 static const int index_phi = 2;
225
226 // sets of coordinates
227 typedef int coords_set;
228
229 // singleton coordinate set for a given index
230 inline coords_set coord_set_of_index(int i) { return 0x1 << i; }
231 static const coords_set set_mu = coord_set_of_index(index_mu );
232 static const coords_set set_nu = coord_set_of_index(index_nu );
233 static const coords_set set_phi = coord_set_of_index(index_phi);
234
235 static const coords_set set_empty = 0;
236 static const coords_set set_all = set_mu | set_nu | set_phi;
237
238 // human-readable coordinate names for debugging etc
239 const char *name_of_index(int c);
240 const char *name_of_coords_set(coords_set S);
241
242 // set complement of coordinates
243 inline coords_set coords_set_not(coords_set S)
244 { return set_all - S; }
245 };
i.e. this ICE is reported in
static const coords_set set_all = set_mu | set_nu | set_phi;
and doesn't seem to have anything to do with assert() .
Any ideas what's going on here? Any suggestions for possible workarounds?
I can easily enough hack up my own fake assert() macro to work around bug #1,
but I have no idea of what's going wrong with my static const int assignments,
and hence no idea of how to work around the problem.
For additional information about the bugs, I am MIME-attaching the files
gcc-v.bug1 script(1) transcript of gcc -v --save-temps for bug #1
coords.ii.bug1.gz resulting coords.ii file (gzipped) for bug #1
gcc-v.bug2 script(1) transcript of gcc -v --save-temps for bug #2
coords.ii.bug2.gz resulting coords.ii file (gzipped) for bug #2
Thanks 1L<<20,
--
-- Jonathan Thornburg <jthorn@galileo.thp.univie.ac.at>
http://www.thp.univie.ac.at/~jthorn/home.html
Universitaet Wien (Vienna, Austria) / Institut fuer Theoretische Physik
"Every one we don't catch would be a "yet another major ms security hole",
and the theory tells us we can't catch all of them. So, we're just not
going to start down that path." --paulle@microsoft.com 1998 Bugtraq
-------------- next part --------------
A non-text attachment was scrubbed...
Name: coords.ii.bug1.gz
Type: application/x-gzip
Size: 15299 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-bugs/attachments/20000229/d325065a/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: coords.ii.bug2.gz
Type: application/x-gzip
Size: 14955 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-bugs/attachments/20000229/d325065a/attachment-0001.bin>
More information about the Gcc-bugs
mailing list