NetBSD-Bugs archive

[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: Joerg Sonnenberger <joerg%bec.de@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: toolchain-manager%netbsd.org@localhost, gnats-admin%netbsd.org@localhost,
	netbsd-bugs%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:
    (x)
    (unsigned short expression)
 
 In the second case, it will be implicitly promoted to int. That's what
 the warning is about.
 
 Joerg
 


Home | Main Index | Thread Index | Old Index