[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gcc-patches
Subject:    Re: [PATCH] Fix 2 clang warnings.
From:       Segher Boessenkool <segher () kernel ! crashing ! org>
Date:       2019-06-29 16:09:36
Message-ID: 20190629160936.GA18316 () gate ! crashing ! org
[Download RAW message or body]

On Thu, Jun 27, 2019 at 08:49:50AM -0600, Martin Sebor wrote:
> On 6/27/19 8:21 AM, Martin Liška wrote:
> >/home/marxin/Programming/gcc/gcc/ggc-page.c:946:60: warning: format 
> >specifies type 'void *' but the argument has type 'char *' 
> >[-Wformat-pedantic]
> 
> I'm normally in favor of cleaning up warnings but this one looks
> worse than useless to me: heeding it makes what's clean, easy t
> read, and perfectly correct and safe code harder to read purely
> for the sake of pedantry.  There is no difference between a char*
> and void*.

There is C11 6.2.5/28:

"A pointer to void shall have the same representation and alignment
requirements as a pointer to a character type."

as clarified by a footnote:

"The same representation and alignment requirements are meant to imply
interchangeability as arguments to functions, return values from
functions, and members of unions."

So I'd say that yes, void * and char * are interchangeable as arguments
to variable argument functions as well.

>  If we want to make an improvement let's propose to
> relax the pointless C requirement that the %p argument be a void*
> and allow it to be any object pointer.

But not this.  There are systems where different pointer types have
different presentation.  There are GCC ports for such systems, even
(maybe none in-tree, but does that matter?)


Segher
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic