This is the mail archive of the 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]
Other format: [Raw text]

[patch] PR c++/21768: ICE in error message due to violation of codingconventions

Compiling the following code snippet with the German locale enabled
causes an ICE:

template<int,int> struct A;
template<int> struct A {};
================================ Fehler: previous declaration »template<int <anonymous>, int <anonymous> > struct A« Fehler: 2 Template-Parameter interner Compiler-Fehler: in pp_base_format_text, bei pretty-print.c:357
  Bitte senden Sie einen vollständigen Fehlerbericht auf Englisch ein;
  bearbeiten Sie die Quellen zunächst mit einem Präprozessor, wenn es
  dienlich ist.
  Fehler in der deutschen Übersetzung sind an zu melden.

  Gehen Sie gemäß den Hinweisen in <URL:> vor.

This is partly due to the fact that the code snippet in cp/pt.c that
generates the original message violates the coding conventions

      error ("used %d template parameter%s instead of %d",
		TREE_VEC_LENGTH (tmpl_parms), 
		TREE_VEC_LENGTH (tmpl_parms) == 1 ? "" : "s",
		TREE_VEC_LENGTH (parms));

The attached patch fixes that by removing the conditional and using
"parameter(s)" in the text. This should simplify i18n efforts.

Alternatively, one could make two messages, one for 1 parameter
and one for 0 or more than 1. But I don't think that this is worthwhile.
Btw, do all languages use the plural form for 0 parameters?
That's an implicit assumption that might not be true.

The ICE with the German locale appeared in gcc 3.4.4 (before we did not
have a German translation for that error message).
Therefore I'd like to apply the patch not only to mainline, but also
to the 3.4 and 4.0 branch as a first step towards removing the ICE.

Bootstrapped and regtested on i686-pc-linux-gnu.
Ok for 3.4 branch, 4.0 branch, and mainline?


2005-05-26  Volker Reichelt  <>

	PR c++/21768
	* pt.c (redeclare_class_template): Change error message according
	to coding conventions.

--- gcc/gcc/cp/pt.c	2005-05-25 00:00:57.000000000 +0200
+++ gcc/gcc/cp/pt.c	2005-05-25 00:35:03.000000000 +0200
@@ -3225,10 +3225,9 @@ redeclare_class_template (tree type, tre
   if (TREE_VEC_LENGTH (parms) != TREE_VEC_LENGTH (tmpl_parms))
       cp_error_at ("previous declaration %qD", tmpl);
-      error ("used %d template parameter%s instead of %d",
-		TREE_VEC_LENGTH (tmpl_parms), 
-		TREE_VEC_LENGTH (tmpl_parms) == 1 ? "" : "s",
-		TREE_VEC_LENGTH (parms));
+      error ("used %d template parameter(s) instead of %d",
+	     TREE_VEC_LENGTH (tmpl_parms), 
+	     TREE_VEC_LENGTH (parms));

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