Subject: compiler warning/bug in FvwmScript/script.y

From: Dominik Vogt <[email-masked]>
Date: Thu, 14 Nov 2002 14:12:28 +0100

script.y had this code:

  foo *some_func()
  {
    if (...)
    {
      ...
      return something;
    }
    else
    {
      return NULL;
      *s = 0;
    }
  }

This generates a compiler warning:

  script.y: In function `Depile':
  script.y:132: warning: control reaches end of non-void function

Olivier, are you sure your gcc works correctly.  You said you
compile with -Wall, so you should have seen this warning/bug.  I
had a problem with gcc a while ago.  When I compiled with
"-Wall -Werror -g" I got no warnings at all, but with
"-Wall -Werror -g -O2" it worked fine.  Are you sure you are not
running into a similar problem?  Can you post one of your compiler
commands?  Mine look like this:

  $ make CFLAGS="-Wall -Werror -g -O2" bindings.o
  source='bindings.c' object='bindings.o' libtool=no \
  depfile='.deps/bindings.Po' tmpdepfile='.deps/bindings.TPo' \
  depmode=gcc /bin/sh ../depcomp \
  gcc -DHAVE_CONFIG_H -I. -I. -I.. -I.. -I../libs
  -I/usr/include/freetype2  -I/usr/X11R6/include   -I/usr/include
  -DFVWM_MODULEDIR=\"/usr/local/libexec/fvwm/2.5.5\"
  -DFVWM_DATADIR=\"/usr/local/share/fvwm\"
  -DFVWM_CONFDIR=\"/usr/local/etc\" -DFVWM_COLORSET_PRIVATE=1 -Wall
  -Werror -g -O2 -c `test -f 'bindings.c' || echo './'`bindings.c

Bye

Dominik ^_^  ^_^
--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]

---

From: Olivier Chapuis <[email-masked]>
Date: Thu, 14 Nov 2002 14:58:08 +0100

>   script.y:132: warning: control reaches end of non-void function

I am surprised by the warning description. A more natural warning
will be something like "code after end of function". I get the
warning if, say, I remove "return NULL".

Note that the code you fix in script.c is there since an eternity
I think. At least it is in 2.4. So, the question why you do not
get such a warning before?
  
> commands?

I (want to) compile like this:

	$ make

which gives:

gcc -DHAVE_CONFIG_H -I. -I. -I../.. -I../..  -I/opt/X11R6-cvs/include \
-I/opt/X11R6-cvs/include/freetype2 -I/opt/X11R6-cvs/include \
-I/opt/X11R6-cvs/include -I/opt/X11R6-cvs/include -I/usr/local/include/fribidi \
-DFVWM_DATADIR=\"/opt/fvwm/share/fvwm\" \
-g -O2 -Wall -Wno-implicit-int -c script.c
       ^^^^^^^^^^^^^^^^^^^^^^^

as I have a colored gcc I rarely miss a warning. But, as I say in a
previous mail I do not know why "-Wno-implicit-int" has been added.
So sometime I miss an implicit int declaration. I would like to
remove this "-Wno-implicit-int" (and we may add an option, --developer,
to configure, which adds -Werror if gcc is the compiler)

Tim I think that you added "-Wno-implicit-int". Why?

Olivier

---

From: "Paul Smith" <[email-masked]>
Date: 14 Nov 2002 10:15:50 -0500

%% Dominik Vogt <[email-masked]> writes:

  dv> When I compiled with "-Wall -Werror -g" I got no warnings at all,
  dv> but with "-Wall -Werror -g -O2" it worked fine.

Some kinds of warnings are not found unless you compile with
optimization.  Enabling the optimizer allows the compiler to look much
more deeply at your code, and that can enable it to discover problems
that can't be found by a simple one-pass compilation.

The most common such warnings are for unused variable: without
optimization on the compiler doesn't know enough about your code to
realize that a variable is never used; only with optimization turned on
will it keep enough state throughout the function to deliver that
warning.

Note that the level of optimization doesn't matter; even -O is good
enough to find the extra warnings (but -O2 is the most common, and so
best-tested, level of optimization in GCC).

FYI.  BTW, all of the above applies to GCC only; other compilers
obviously may have different behavior.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <[email-masked]> HASMAT--HA Software Mthds & Tools
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist
-------------------------------------------------------------------------------
   These are my opinions---Nortel Networks takes no responsibility for them.
--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]

---

From: Dominik Vogt <[email-masked]>
Date: Thu, 14 Nov 2002 16:54:52 +0100

> will it keep enough state throughout the function to deliver that

Heck!  Why isn't that mentioned in the gcc info page?!  So I can't
have debuggable code and many important warnings at the same time?
What really pisses me off during debugging sessions is when gcc
optimizes local variables away.

Bye

Dominik ^_^  ^_^

---

From: "Paul Smith" <[email-masked]>
Date: 14 Nov 2002 11:04:59 -0500

dv> Heck!  Why isn't that mentioned in the gcc info page?!

You mean like this:

     These warnings are possible only in optimizing compilation,
     because they require data flow information that is computed only
     when optimizing.  If you don't specify `-O', you simply won't get
     these warnings.

? :)

  dv> So I can't have debuggable code and many important warnings at the
  dv> same time?

Yep.  I agree it's a drag--I've often felt that the -O0 flag or
something should have a side-effect of doing the optimization warning
checks, but then not actually optimizing the resulting code.

Actually I'm not sure about "many important warnings"; I think the only
two warnings which are enabled only for optimization are uninitialized
variables (which is certainly important, I grant you) and "nonvolatile
automatic variables being changed by longjmp"... which is rarely
useful.

I misspoke last time about the unused variables: those are warned even
without -O.  It's the uninitialized variables that aren't warned unless
you enable -O.

---

From: Dominik Vogt <[email-masked]>
Date: Thu, 14 Nov 2002 17:44:14 +0100

>      when optimizing.  If you don't specify `-O', you simply won't get

Sorry, I somehow missed that paragraph.  I just can't operate info
:-/  At least it should throw a warning that it does not generate
these warnings ;-)

> variables

> (which is certainly important, I grant you)

Especially when you are used to rely on it.

> and "nonvolatile

Bye

Dominik ^_^  ^_^

---

From: Cameron Simpson <[email-masked]>
Date: Fri, 15 Nov 2002 10:32:45 +1100

On 17:44 14 Nov 2002, Dominik Vogt <[email-masked]> wrote:
| On Thu, Nov 14, 2002 at 11:04:59AM -0500, Paul Smith wrote:
| > %% Dominik Vogt <[email-masked]> writes:
| >   dv> Heck!  Why isn't that mentioned in the gcc info page?!
| > 
| > You mean like this:
| >      These warnings are possible only in optimizing compilation, [...]
| > ? :)
| 
| Sorry, I somehow missed that paragraph.  I just can't operate info
| :-/

You may want my "man" script, which presents info as one of the choices
for manual pages. More to the point, it parses info files and turns them
into a single flat text document, which of course you browse with your
pager as with ordinary manual entries. It's certainly made info accessable
for me. To be sure, there are no hyperlinks, but the link targets _are_
presented in the text, and the your pager's search function should find
them fairly well.

Just FYI. Cheers,
-- 
Cameron Simpson, DoD#743        [email-masked]    http://www.zip.com.au/~cs/

I'd hate to be one to quibble over grammar, but your statement above is
fallacious even if true.	- [email-masked] (Bill Conner)
--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]

---

From: "Paul Smith" <[email-masked]>
Date: 14 Nov 2002 18:50:47 -0500

%% Cameron Simpson <[email-masked]> writes:

  cs> You may want my "man" script, which presents info as one of the
  cs> choices for manual pages. More to the point, it parses info files
  cs> and turns them into a single flat text document, which of course
  cs> you browse with your pager as with ordinary manual entries.

Info is quite accessible if you spend a few minutes learning the
command set--there are only about 10 keys :).

In particular, the "s" (search) and "i" (index lookup) are critically
important to know.  Once you know these you can do more with Info that
you can do with either man pages or HTML.

---

From: Dominik Vogt <[email-masked]>
Date: Fri, 15 Nov 2002 10:00:07 +0100

>   cs> you browse with your pager as with ordinary manual entries.

Yes, please!  That's exactly what I need!

> command set--there are only about 10 keys :).

I have spent five years and can not get the hang of it.

> you can do with either man pages or HTML.

I really don't want to rant about the interface of info here.  Let
it suffice to say that I absolutely *hate* hierarchical documents.
And info operates a bit like vi, a bit like lynx and a bit like
emacs, but not quite.  That totally confuses me.

Bye

Dominik ^_^  ^_^

---

From: Cameron Simpson <[email-masked]>
Date: Sat, 16 Nov 2002 12:20:46 +1100

On 10:00 15 Nov 2002, Dominik Vogt <[email-masked]> wrote:
| On Thu, Nov 14, 2002 at 06:50:47PM -0500, Paul Smith wrote:
| > %% Cameron Simpson <[email-masked]> writes:
| >   | Sorry, I somehow missed that paragraph.  I just can't operate info
| >   | :-/
| >   cs> You may want my "man" script, which presents info as one of the
| >   cs> choices for manual pages. More to the point, it parses info files
| >   cs> and turns them into a single flat text document, which of course
| >   cs> you browse with your pager as with ordinary manual entries.
| 
| Yes, please!  That's exactly what I need!

Start here:

	http://www.zip.com.au/~cs/css/index.html#s-text-info2x

and get the info2man.tar.gz file and also fetch:

	http://www.zip.com.au/~cs/scripts/man

which is the script itself. You then add the info dirs to your $MANPATH
and go. It may have a few dependencies on my environment which I'd be
happy to iron out, so let me know if it gives you trouble. In particular
it expects the envvar $OS to be "linux" on linux systems (well, actually
groff-based systems). Hmm, I see there's now an nroff on my redhat box, so
maybe you won't need the groff incantation at all.

[...]
| > In particular, the "s" (search) and "i" (index lookup) are critically
| > important to know.  Once you know these you can do more with Info that
| > you can do with either man pages or HTML.
| 
| I really don't want to rant about the interface of info here.  Let
| it suffice to say that I absolutely *hate* hierarchical documents.
| And info operates a bit like vi, a bit like lynx and a bit like
| emacs, but not quite.  That totally confuses me.

I would second that hierachical remark - I also really hate limping
through HOWTO web documents which are typically presented in pieces :-(
And I generally want a big document in the pager my fingers know.

Cheers,

... that, in a few years, all great physical constants will have been
approximately estimated, and that the only occupation which will be
left to men of science will be to carry these measurements to another
place of decimals.	- James Clerk Maxwell (1813-1879) 
			  Scientific Papers 2, 244, October 1871
--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]