This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
error message improvement.
- To: egcs-patches at cygnus dot com
- Subject: error message improvement.
- From: Geoff Keating <geoffk at ozemail dot com dot au>
- Date: Tue, 5 Jan 1999 22:36:03 +1100
I was using egcs 1.1.1 and it came up with this warning message:
libm-test.inc:6195: warning: ediv invalid operation error
I found this somewhat unhelpful. I had to read the sources to work
out that what it meant was that a division had produced NaN:
[geoffk@geoffk /tmp]$ cat > z.c <<EOF
> double bar(void)
> {
> return 0./0.;
> }
> EOF
[geoffk@geoffk /tmp]$ gcc -W z.c -S
z.c: In function `bar':
z.c:3: warning: ediv invalid operation error
It also doesn't help that the error message refers to the last line of
the procedure in which the problem occurred, and that usually such
unusual operation results are referred to as "exceptions", not errors
(because they may make perfect sense, in fact the case I saw was
intentionally trying to produce a NaN).
I propose the following patch. It would produce, for this case,
[geoffk@geoffk /tmp]$ cc1 -W -quiet z.c -o z.s
z.c: In function `bar':
z.c:3: warning: `not-a-number' produced during real division
which only leaves the line number problem...
--
Geoffrey Keating <geoffk@ozemail.com.au>
===File ~/patches/egcs-10.diff==============================
Tue Jan 5 10:24:30 1998 Geoff Keating <geoffk@ozemail.com.au>
* real.c (mtherr): Print more reasonable warning messages.
--- egcs-1.1.1/gcc/real.c~ Tue Jun 30 07:40:04 1998
+++ egcs-1.1.1/gcc/real.c Tue Jan 5 22:23:50 1999
@@ -5596,13 +5596,13 @@
static char *ermsg[NMSGS] =
{
"unknown", /* error code 0 */
- "domain", /* error code 1 */
+ "domain error", /* error code 1 */
"singularity", /* et seq. */
"overflow",
"underflow",
"total loss of precision",
"partial loss of precision",
- "invalid operation"
+ "`not-a-number' produced"
};
int merror = 0;
@@ -5621,7 +5621,23 @@
if ((code <= 0) || (code >= NMSGS))
code = 0;
- sprintf (errstr, " %s %s error", name, ermsg[code]);
+ if (strcmp (name, "esub") == 0)
+ name = "subtraction";
+ else if (strcmp (name, "ediv") == 0)
+ name = "division";
+ else if (strcmp (name, "emul") == 0)
+ name = "multiplication";
+ else if (strcmp (name, "enormlz") == 0)
+ name = "normalization";
+ else if (strcmp (name, "etoasc") == 0)
+ name = "conversion to text";
+ else if (strcmp (name, "asctoe") == 0)
+ name = "parsing";
+ else if (strcmp (name, "eremain") == 0)
+ name = "modulus";
+ else if (strcmp (name, "esqrt") == 0)
+ name = "square root";
+ sprintf (errstr, "%s during real %s", ermsg[code], name);
if (extra_warnings)
warning (errstr);
/* Set global error message word */
============================================================