public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: mtodorov@alu.hr
To: gcc-gnats@gcc.gnu.org
Subject: c/2776: Wrong (misleading) error message in gcc 2.95.3
Date: Tue, 08 May 2001 10:56:00 -0000	[thread overview]
Message-ID: <20010508174624.17779.qmail@sourceware.cygnus.com> (raw)

>Number:         2776
>Category:       c
>Synopsis:       Wrong (misleading) error message in gcc 2.95.3
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Tue May 08 10:56:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Mirsad Todorovac
>Release:        gcc 2.95.3
>Organization:
>Environment:
alpha-dec-osf4.0b
gcc-2.95.3
gmake 3.79
tcsh 6.10.00

>Description:
When the following code was compiled:

 99        if(_GrFontFileInfo.npath < 0) {
100            char *fPath = getenv("GRXFONT");
101 #ifdef GRX_DEFAULT_FONT_PATH
102             if (!fPath) fPath = GRX_DEFAULT_FONT_PATH;
103 #endif
104            GrSetFontPath(fPath);
105        }


gcc 2.95.3 returned following error message:

text/loadfont.c:102: parse error before `/'
text/loadfont.c:102: warning: empty body in an if-statement

Gcc was invoked by gmake with following options:
gcc -c -O6 -Wall -W -Wshadow -Wpointer-arith \
-Wbad-function-cast -Wcast-align -Wconversion \
-Wmissing-prototypes -Wnested-externs -Wstrict-prototypes \
-DGRX_DEFAULT_FONT_PATH="/usr/local/lib/grx/fonts" \
-DSMALL_STACK -fomit-frame-pointer -D__XWIN__ -I. \
-I./include -I../include -I/usr/X11R6/include \
-I../addons/print -I../addons/bmp text/loadfont.c \
-o text/loadfont.o

I couldn't decrypt what it meant until I tried gcc -E
(running preprocessor to see what the compiler is really
looking at) and I carefully found the line 102 of
loadfont.c after header inclusion. I've found this:

 99        if(_GrFontFileInfo.npath < 0) {
100            char *fPath = getenv("GRXFONT");
101
102         if (!fPath) fPath = /usr/local/lib/grx/fonts ;
103
104            GrSetFontPath(fPath);
105        }

Now it's obvious what the error is: the path was left
without quotes, although in Makefile it has quotes (the
shell probably stripped them).

But from error message "empty body in an if-statement" it
cannot be seen.

The right error message should be "invalid expression"
or something like that. I understand that gcc can't
"see" that this is actually an error in macro definition
of GRX_DEFAULT_FONT_PATH.

Changing definition of GRX_DEFAULT_FONT_PATH to
\"/usr/local/lib/grx/fonts\" resolved the problem with
GRX build (as for now), but misleading error message in
gcc remains ...

Mirsad Todorovac
>How-To-Repeat:
cat > repeat.c
int main(int argc, char* argv[])
{
        char *fPath = 0;

        if (!fPath) fPath = /usr/local/share/grx/fonts ;
}
^D

gcc -c -O6 -Wall -W -Wshadow -Wpointer-arith \
-Wbad-function-cast -Wcast-align -Wconversion \
-Wmissing-prototypes -Wnested-externs -Wstrict-prototypes \
-DGRX_DEFAULT_FONT_PATH=\"/usr/local/lib/grx/fonts\" \
-DSMALL_STACK -fomit-frame-pointer repeat.c

>Fix:
Try to give a correct error message, like
"bad expression: have you forgot quotes on '/usr/local/lib/grx/fonts'?"
>Release-Note:
>Audit-Trail:
>Unformatted:


             reply	other threads:[~2001-05-08 10:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-05-08 10:56 mtodorov [this message]
2003-02-19 14:06 Steven Bosscher
2003-02-19 14:27 bangerth
2003-02-19 16:56 Mirsad Todorovac
2003-02-19 17:06 Wolfgang Bangerth
2003-02-19 18:56 Mirsad Todorovac

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20010508174624.17779.qmail@sourceware.cygnus.com \
    --to=mtodorov@alu.hr \
    --cc=gcc-gnats@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).