public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Selectiv on/off-turning of warnings
@ 2000-03-22 15:13 Enrico Scholz
  2000-03-22 15:58 ` Martin v. Loewis
  0 siblings, 1 reply; 7+ messages in thread
From: Enrico Scholz @ 2000-03-22 15:13 UTC (permalink / raw)
  To: gcc

Does there exists a possibility to turn off some warnings in certain
parts of the code?

E.g. stuff like "-Weffc++" can detect a lot of nasty errors but it takes
effect on the whole compilation unit---inclusive included system headers
violating style-guides because of performance-purposes. So I get a lot
of useless warnings in which the "real" ones (those _I_ am responsible
for) are hidden.

This happens not only with "-Weffc++", "-ansi -pedantic" produces
e.g.:
/usr/include/g++-3/std/straits.h:86: warning: ANSI C++ forbids variable-size array `a'


A reasonable solution could be something like:

-----
#pragma warnings push
#pragma warnings -effc++
#include <unistd.h>
#pragma warnings pop
-----


Or have I overseen another already existing possibility?





Enrico

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Selectiv on/off-turning of warnings
  2000-03-22 15:13 Selectiv on/off-turning of warnings Enrico Scholz
@ 2000-03-22 15:58 ` Martin v. Loewis
  2000-03-22 17:21   ` Mo McKinlay
                     ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Martin v. Loewis @ 2000-03-22 15:58 UTC (permalink / raw)
  To: Enrico.Scholz; +Cc: gcc

> Does there exists a possibility to turn off some warnings in certain
> parts of the code?

Not at the moment, no. It is a frequently-discussed topic, with
proponents and people arguing against it. So far, these discussions
never caused any actions.

> This happens not only with "-Weffc++", "-ansi -pedantic" produces
> e.g.:
> /usr/include/g++-3/std/straits.h:86: warning: ANSI C++ forbids variable-size array `a'

Well, that's clearly a bug in straits.h. The correct action would be
to fix that, instead of providing more options to the compiler. The
compiler does not produce certain warnings for system header files.

> A reasonable solution could be something like:

I think there would be a long debate whether it is reasonable. For one
thing, some people claim that #pragma is not reasonable. Since the
standard says a compiler can do anything it wants when it sees a
#pragma, I believe some version of gcc used to invoke Emacs when it
saw a #pragma :-)

Regards,
Martin

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Selectiv on/off-turning of warnings
  2000-03-22 15:58 ` Martin v. Loewis
@ 2000-03-22 17:21   ` Mo McKinlay
  2000-03-22 18:27   ` Enrico Scholz
  2000-03-23  5:05   ` Joern Rennecke
  2 siblings, 0 replies; 7+ messages in thread
From: Mo McKinlay @ 2000-03-22 17:21 UTC (permalink / raw)
  To: Martin v. Loewis; +Cc: Enrico.Scholz, gcc

# I think there would be a long debate whether it is reasonable. For one
# thing, some people claim that #pragma is not reasonable. Since the
# standard says a compiler can do anything it wants when it sees a
# #pragma, I believe some version of gcc used to invoke Emacs when it
# saw a #pragma :-)

Certainly the Borland compilers rely heavily on #pragmas all sorts of
things - mostly for function-local warning selection, but it does cover
other bases too, such as controlling precompiled headers (#pragma
hdrstop). 

My personal view is that there should never be #pragmas implemented that
affect code generation, because it doesn't help portability issues any
(#pragma itself doesn't, but relying on it to alter code generation
behavior would be much worse, IMVHO). 

-- 
Mo McKinlay                                T: +44 (0) 709 22 55 05  x1
Chief Software Architect                   F: +44 (0) 709 22 55 05  x3
inter/open                                 E: mmckinlay@labs.interopen.org
A division of Bekon Marketing Limited      W: http://www.interopen.org

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Selectiv on/off-turning of warnings
  2000-03-22 15:58 ` Martin v. Loewis
  2000-03-22 17:21   ` Mo McKinlay
@ 2000-03-22 18:27   ` Enrico Scholz
  2000-03-23  0:18     ` Martin v. Loewis
  2000-03-23  5:05   ` Joern Rennecke
  2 siblings, 1 reply; 7+ messages in thread
From: Enrico Scholz @ 2000-03-22 18:27 UTC (permalink / raw)
  To: Martin v. Loewis; +Cc: Enrico.Scholz, gcc

"Martin v. Loewis" <martin@loewis.home.cs.tu-berlin.de> writes:

> [...]
> > This happens not only with "-Weffc++", "-ansi -pedantic" produces
> > e.g.:
> > /usr/include/g++-3/std/straits.h:86: warning: ANSI C++ forbids variable-size array `a'
> 
> Well, that's clearly a bug in straits.h. The correct action would be
> to fix that, instead of providing more options to the compiler.

AFAIK variable-sized arrays are an extension of gcc. I have tried to put
"__extension__" in front of "char_type a[n];", but the warning remains.


> The compiler does not produce certain warnings for system header
> files.

Limiting this behavior to system-headers only is not a solution. Often
there are third-party libraries which are using non-standard features in
a right manner also (that means ./configure or something else tested
their existence and correct behavior). An example is pointer-arithmetic.

Often I just want to develope _my_ sources _now_ and have not the time
or know-how to modify the 3rd-party interface in a way that the warnings
do not occur anymore or to wait for such a modification.

Grepping the gcc-output seems to be the only way to reach that, but I
don't like it because another layer will be introduced which needs
maintenance and disables some features (e.g. recursive-building of
automake).


> > A reasonable solution could be something like:
> 
> I think there would be a long debate whether it is reasonable. For
> one thing, some people claim that #pragma is not reasonable.

Well, #pragma was just a incidence I had. Usage of a language-extension
like __gcc_warnings_enable__ is possible also. I am not sure if the
_Pragma() operator mentioned in other threads is reasonable, because
only C99 knows it but not C++.

I would wonder if such minor technical details can influence the decision
about importing such an option...


> Since the standard says a compiler can do anything it wants when it
> sees a #pragma, I believe some version of gcc used to invoke Emacs
> when it saw a #pragma :-)

I know, but I think these gcc versions misuse^H^H^Hinterpreted the
standard. The standard says (a little bit laxly) that any #pragma that
is not recognized will be ignored.

Supporter of the Emacs-version will say, gcc knows _all_ #pragma's; but
because the case of unrecognized #pragma's is mentioned explicitly I
assume that their amount can not be empty. :)




Enrico

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Selectiv on/off-turning of warnings
  2000-03-22 18:27   ` Enrico Scholz
@ 2000-03-23  0:18     ` Martin v. Loewis
  0 siblings, 0 replies; 7+ messages in thread
From: Martin v. Loewis @ 2000-03-23  0:18 UTC (permalink / raw)
  To: Enrico.Scholz; +Cc: Enrico.Scholz, gcc

> AFAIK variable-sized arrays are an extension of gcc. I have tried to put
> "__extension__" in front of "char_type a[n];", but the warning remains.

Could you please report this as a bug? I tried to come up with an
example showing the error, but couldn't.

> I would wonder if such minor technical details can influence the
> decision about importing such an option...

Well, there never was anything to import, so it is hard to tell
whether it would influence a decision. As I said, the primary reason
for the feature not being there is that it was never implemented;
please have a look at

http://gcc.gnu.org/cgi-bin/fom.cgi?file=12

Most people trying to get that feature had been following the
"convince compiler authors" route, and they failed so far because
every proposal had "minor technical problems". Apparently, none of the
authors is willing to invest any amount of time for adding a #pragma,
if they think pragmas are a stupid idea to begin with. In case you
write a patch for gcc, please send it to gcc-patches@gcc.gnu.org.

Regards,
Martin

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Selectiv on/off-turning of warnings
  2000-03-22 15:58 ` Martin v. Loewis
  2000-03-22 17:21   ` Mo McKinlay
  2000-03-22 18:27   ` Enrico Scholz
@ 2000-03-23  5:05   ` Joern Rennecke
  2000-03-23  9:04     ` Jeffrey A Law
  2 siblings, 1 reply; 7+ messages in thread
From: Joern Rennecke @ 2000-03-23  5:05 UTC (permalink / raw)
  To: Martin v. Loewis; +Cc: Enrico.Scholz, gcc

> I think there would be a long debate whether it is reasonable. For one
> thing, some people claim that #pragma is not reasonable. Since the
> standard says a compiler can do anything it wants when it sees a
> #pragma, I believe some version of gcc used to invoke Emacs when it
> saw a #pragma :-)

The code is still in cccp.c, although it is #ifdefed out these days:

#if 0
/* This was a fun hack, but #pragma seems to start to be useful.
   By failing to recognize it, we pass it through unchanged to cc1.  */

/* The behavior of the #pragma directive is implementation defined.
   this implementation defines it as follows.  */

static int
do_pragma ()
{
  close (0);
  if (open ("/dev/tty", O_RDONLY, 0666) != 0)
    goto nope;
  close (1);
  if (open ("/dev/tty", O_WRONLY, 0666) != 1)
    goto nope;
  execl ("/usr/games/hack", "#pragma", 0);
  execl ("/usr/games/rogue", "#pragma", 0);
  execl ("/usr/new/emacs", "-f", "hanoi", "9", "-kill", 0);
  execl ("/usr/local/emacs", "-f", "hanoi", "9", "-kill", 0);
nope:
  fatal ("You are in a maze of twisty compiler features, all different");
}
#endif

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Selectiv on/off-turning of warnings
  2000-03-23  5:05   ` Joern Rennecke
@ 2000-03-23  9:04     ` Jeffrey A Law
  0 siblings, 0 replies; 7+ messages in thread
From: Jeffrey A Law @ 2000-03-23  9:04 UTC (permalink / raw)
  To: Joern Rennecke; +Cc: Martin v. Loewis, Enrico.Scholz, gcc

  In message < 200003231304.NAA16792@phal.cygnus.co.uk >you write:
  > > I think there would be a long debate whether it is reasonable. For one
  > > thing, some people claim that #pragma is not reasonable. Since the
  > > standard says a compiler can do anything it wants when it sees a
  > > #pragma, I believe some version of gcc used to invoke Emacs when it
  > > saw a #pragma :-)
  > 
  > The code is still in cccp.c, although it is #ifdefed out these days:
[ ... ]
Feel free to just remove that code.  While it was an interesting hack 10
years ago, it's really not appropriate anymore.
jeff

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2000-03-23  9:04 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-03-22 15:13 Selectiv on/off-turning of warnings Enrico Scholz
2000-03-22 15:58 ` Martin v. Loewis
2000-03-22 17:21   ` Mo McKinlay
2000-03-22 18:27   ` Enrico Scholz
2000-03-23  0:18     ` Martin v. Loewis
2000-03-23  5:05   ` Joern Rennecke
2000-03-23  9:04     ` Jeffrey A Law

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).