[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: toolchain/53618: bogus warnings from printf %u and ntohs with -O1
The following reply was made to PR toolchain/53618; it has been noted by GNATS.
From: Valery Ushakov <uwe%stderr.spb.ru@localhost>
Subject: Re: toolchain/53618: bogus warnings from printf %u and ntohs with -O1
Date: Fri, 21 Sep 2018 14:16:01 +0300
On Fri, Sep 21, 2018 at 07:40:01 +0000, Joerg Sonnenberger wrote:
> From: Joerg Sonnenberger <joerg%bec.de@localhost>
> To: gnats-bugs%NetBSD.org@localhost
> Cc: toolchain-manager%netbsd.org@localhost, gnats-admin%netbsd.org@localhost,
> Subject: Re: toolchain/53618: bogus warnings from printf %u and ntohs with -O1
> Date: Fri, 21 Sep 2018 09:36:59 +0200
> On Wed, Sep 19, 2018 at 03:40:00AM +0000, murray+net%ip-64-139-1-69.sjc.megapath.net@localhost wrote:
> > The test case below gets warnings like the following:
> > foo.c:17:10: warning: format '%u' expects argument of type 'unsigned int', but argument 2 has type 'int' [-Wformat=]
> > printf("Foo %u\n", ntohs(x));
> ntohs(x) has two possible expansions:
> (unsigned short expression)
> In the second case, it will be implicitly promoted to int. That's what
> the warning is about.
Isn't that what the 'h' length modifier (i.e. "%hu") is for?
Main Index |
Thread Index |