This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

misleading warning message


gcc 6.3.0, compile this:

#include <stdio.h>

int main(void)
{
    printf("%Ld\n",3L);
    printf("%llf\n", 3.3L);
    return 0;
}

this is the output:
$ gcc -pedantic -std=c99 -Wall test.c -o test
test.c: In function ‘main’:
test.c:5:12: warning: ISO C does not support the ‘%Ld’ gnu_printf format [-Wformat=]
  printf("%Ld\n",3L);
            ^
test.c:5:12: warning: format ‘%Ld’ expects argument of type ‘long long int’, but argument 2 has type ‘long int’ [-Wformat=] test.c:6:13: warning: use of ‘ll’ length modifier with ‘f’ type character has either no effect or undefined behavior [-Wformat=]
  printf("%llf\n", 3.3L);
             ^

the warning about '%Ld' is misleading. I was expecting something like "use of ‘L’ length modifier with ‘d’ type character has either no effect or undefined behavior", otherwise it looks that '%Ld' is allowed and require ‘long long int’.

also printf(3) manpage says:

*"L:* A following *a*, *A*, *e*, *E*, *f*, *F*, *g*, or *G* conversion corresponds to a /long double/ argument."


--

Powersoft logo <http://www.powersoft.it>

*Massimiliano Cialdi |*Senior Firmware Engineer

*skype:* mci.pws *| email:* massimiliano.cialdi@powersoft.it <mailto:massimiliano.cialdi@powersoft.it>

*HQ Italy:* Via E. Conti, 5 *|* 50018 Scandicci (FI) Italy

*direct phone:*  +39 055 0153429 *| Fax:*  +39 055 735 6235

*web site:* www.powersoft.it <http://www.powersoft.it>

Green Audio Power


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]