This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
misleading warning message
- From: massimiliano cialdi <massimiliano dot cialdi at powersoft dot it>
- To: gcc-help at gcc dot gnu dot org
- Date: Wed, 7 Jun 2017 23:11:26 +0200
- Subject: misleading warning message
- Authentication-results: sourceware.org; auth=none
- Authentication-results: gcc.gnu.org; dkim=none (message not signed) header.d=none;gcc.gnu.org; dmarc=none action=none header.from=powersoft.it;
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
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