This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

New bad bug in initialization of static arrays


Greetings,

	The following short piece of code compiles fine using
	egcs-2.91.66, but not 2.95.1:

class HepString {
public:
  inline HepString();
  // Constructs empty string.

  HepString(const char *);
  // Constructs string from a character array.

  inline ~HepString();
  // Destroys string, deallocating storage.
};

const HepString names[10][5] = {
  { "b1(1235)",   "h1(1170)",   "h1(1380)",      "k1(1270)",      "k1(1270)" },
  { "a0(1450)",   "f0(1370)",           "", "k0_star(1430)", "k0_star(1430)" },
  { "a1(1260)",   "f1(1285)",   "f1(1420)",      "k1(1400)",      "k1(1400)" },
  { "a2(1320)",   "f2(1270)","f2_prime(1525)","k2_star(1430)","k2_star(1430)"},
  {"pi2(1670)", "eta2(1645)", "eta2(1870)",      "k2(1770)",      "k2(1770)" },
  {"rho(1700)", "omega(1600)",          "",  "k_star(1680)",  "k_star(1680)" },
 {"rho3(1690)","omega3(1670)","phi3(1850)", "k3_star(1780)", "k3_star(1780)" },
  { "pi(1300)",  "eta(1295)",  "eta(1440)",       "k(1460)",       "k(1460)" },
  {"rho(1450)","omega(1420)",  "phi(1680)",  "k_star(1410)",  "k_star(1410)" },
  {         "",   "f2(1810)",   "f2(2010)", "k2_star(1980)", "k2_star(1980)" }
};
////////////////////////////////////////////////////////////////


	In the new compiler, it produces the following irrational
	error message ten times:

testqqq.cc:14: conversion from `const HepString[5]' to non-scalar type `HepString' requested

	Obviously, the compiler was never asked to convert from
	"const HepString[5]" to "HepString".  It must be confused.
	Here is the complete set of information as requested in
	http://www.fsf.org/software/gcc/faq.html#bugreport:


[gas@radon1 ~]$ g++ -v --save-temps testqqq.cc
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.1/specs
gcc version 2.95.1 19990816 (release)
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.1/cpp -lang-c++ -v -D__GNUC__=2 -D__GNUG__=2 -D__GNUC_MINOR__=95 -D__cplusplus -D__ELF__ -Dunix -D__i386__ -Dlinux -D__ELF__ -D__unix__ -D__i386__ -D__linux__ -D__unix -D__linux -Asystem(posix) -D__EXCEPTIONS -Acpu(i386) -Amachine(i386) -Di386 -D__i386 -D__i386__ -Di686 -Dpentiumpro -D__i686 -D__i686__ -D__pentiumpro -D__pentiumpro__ testqqq.cc testqqq.ii
GNU CPP version 2.95.1 19990816 (release) (i386 Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.1/../../../../include/g++-3
 /usr/local/include
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.1/../../../../i686-pc-linux-gnu/include
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.1/include
 /usr/include
End of search list.
The following default directories have been omitted from the search path:
End of omitted list.
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.1/cc1plus testqqq.ii -quiet -dumpbase testqqq.cc -version -o testqqq.s
GNU C++ version 2.95.1 19990816 (release) (i686-pc-linux-gnu) compiled by GNU C version 2.95.1 19990816 (release).
testqqq.cc: In function `void __static_initialization_and_destruction_0(int, int)':
testqqq.cc:14: conversion from `const HepString[5]' to non-scalar type `HepString' requested
testqqq.cc:14: conversion from `const HepString[5]' to non-scalar type `HepString' requested
testqqq.cc:14: conversion from `const HepString[5]' to non-scalar type `HepString' requested
testqqq.cc:14: conversion from `const HepString[5]' to non-scalar type `HepString' requested
testqqq.cc:14: conversion from `const HepString[5]' to non-scalar type `HepString' requested
testqqq.cc:14: conversion from `const HepString[5]' to non-scalar type `HepString' requested
testqqq.cc:14: conversion from `const HepString[5]' to non-scalar type `HepString' requested
testqqq.cc:14: conversion from `const HepString[5]' to non-scalar type `HepString' requested
testqqq.cc:14: conversion from `const HepString[5]' to non-scalar type `HepString' requested
testqqq.cc:14: conversion from `const HepString[5]' to non-scalar type `HepString' requested

[gas@radon1 ~]$ cat testqqq.ii
# 1 "testqqq.cc"

class HepString {
public:
  inline HepString();
   

  HepString(const char *);
   

  inline ~HepString();
   
};

const HepString names[10][5] = {
  { "b1(1235)",   "h1(1170)",   "h1(1380)",      "k1(1270)",      "k1(1270)" },
  { "a0(1450)",   "f0(1370)",           "", "k0_star(1430)", "k0_star(1430)" },
  { "a1(1260)",   "f1(1285)",   "f1(1420)",      "k1(1400)",      "k1(1400)" },
  { "a2(1320)",   "f2(1270)","f2_prime(1525)","k2_star(1430)","k2_star(1430)"},
  {"pi2(1670)", "eta2(1645)", "eta2(1870)",      "k2(1770)",      "k2(1770)" },
  {"rho(1700)", "omega(1600)",          "",  "k_star(1680)",  "k_star(1680)" },
 {"rho3(1690)","omega3(1670)","phi3(1850)", "k3_star(1780)", "k3_star(1780)" },
  { "pi(1300)",  "eta(1295)",  "eta(1440)",       "k(1460)",       "k(1460)" },
  {"rho(1450)","omega(1420)",  "phi(1680)",  "k_star(1410)",  "k_star(1410)" },
  {         "",   "f2(1810)",   "f2(2010)", "k2_star(1980)", "k2_star(1980)" }
};
////////////////////////////////////////////////////////////////

	Note that the above demonstration code doesn't actually do
	anything (other than demonstrate the bug).  The bug was
	initially found when attempting to compile Geant4.0.1
	from CERN, which is known to compile and execute just fine
	with egcs-2.91.60.

	I hope you can identify and fix this one quickly, because
	it seems like a real problem.

	Keep up the good work!
						Sincerely,
						Glenn Horton-Smith
						gas@awa.tohoku.ac.jp


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]