[19474] in Kerberos_V5_Development

home help back first fref pref prev next nref lref last post

Re: Making discarded-qualifiers a gcc error instead of warning?

daemon@ATHENA.MIT.EDU (Benjamin Kaduk)
Thu Sep 1 23:23:03 2016

Date: Thu, 1 Sep 2016 23:22:43 -0400 (EDT)
From: Benjamin Kaduk <kaduk@mit.edu>
To: Will Fiveash <will.fiveash@oracle.com>
In-Reply-To: <20160902002300.GA15711@oracle.com>
Message-ID: <alpine.GSO.1.10.1609012321510.5272@multics.mit.edu>
MIME-Version: 1.0
Cc: krbdev@mit.edu
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: krbdev-bounces@mit.edu

On Thu, 1 Sep 2016, Will Fiveash wrote:

> On Thu, Sep 01, 2016 at 05:56:15PM -0500, Will Fiveash wrote:
> > I'm in the process of making the Solaris compile of MIT krb more strict
> > and one thing I've noticed in the MIT build environment is that
> > -Wdiscarded-qualifiers is being treated by gcc as a warning, not an
> > error.  Given there are only three of these types of warnings in the
> > entire 1.14.3 code base I was wondering if y'all would consider making
> > discarded-qualifiers an error and adding a cast to the three lines in
> > the source files that need it?
>
> Related to this, the current MIT gcc settings allows:
>
> #include <stdio.h>
> #include <stdlib.h>
>
> void
> foo(char *arg)
> {
> 	printf("arg is %p\n", arg);
> 	return;
> }
>
> int
> main (int argc, char *argv[])
> {
> 	char *bad;
>
> 	foo(&bad);  /* <----- this should just be bad */
> }
>
> to compile without a hard error (a -Wincompatible-pointer-types warning
> is issued).  Shouldn't this bug also cause gcc to error out?

char * is explicitly compatible with every (non-function) pointer type in
the C standard.  So this particular example should not necessarily error
out, though the analogous one with int* should.

-Ben
_______________________________________________
krbdev mailing list             krbdev@mit.edu
https://mailman.mit.edu/mailman/listinfo/krbdev

home help back first fref pref prev next nref lref last post