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



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