public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/54361] New: Compiling for c++11 gives a warning on scanf() with %as format specifier
@ 2012-08-23 23:34 strikosn at gmail dot com
2012-08-23 23:35 ` [Bug c++/54361] " strikosn at gmail dot com
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: strikosn at gmail dot com @ 2012-08-23 23:34 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54361
Bug #: 54361
Summary: Compiling for c++11 gives a warning on scanf() with
%as format specifier
Classification: Unclassified
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: strikosn@gmail.com
Target: x86_64-unknown-linux-gnu
Configured with: /home/utils/src/gcc-4.7.0/configure
--prefix=/home/utils/gcc-4.7.0 --enable-languages=c,c++,objc,fortran
--with-gmp=/home/utils/gmp-5.0.2-static
--with-mpfr=/home/utils/mpfr-3.1.0-static --with-mpc=/home/utils/mpc-0.9-static
--with-as=/home/utils/binutils-2.21.1/bin/as
--with-ld=/home/utils/binutils-2.21.1/bin/ld
Thread model: posix
gcc version 4.7.0 (GCC)
Source code attached as c.cpp
$ g++ -std=c++11 -Wall -Werror c.cpp
c.cpp: In function 'int main()':
c.cpp:10:26: error: format '%a' expects argument of type 'float*', but argument
2 has type 'char**' [-Werror=format]
c.cpp:7:7: error: unused variable 'a' [-Werror=unused-variable]
cc1plus: all warnings being treated as errors
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/54361] Compiling for c++11 gives a warning on scanf() with %as format specifier
2012-08-23 23:34 [Bug c++/54361] New: Compiling for c++11 gives a warning on scanf() with %as format specifier strikosn at gmail dot com
@ 2012-08-23 23:35 ` strikosn at gmail dot com
2012-08-23 23:54 ` jakub at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: strikosn at gmail dot com @ 2012-08-23 23:35 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54361
--- Comment #1 from Nick Strikos <strikosn at gmail dot com> 2012-08-23 23:35:31 UTC ---
Created attachment 28075
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28075
Testcase
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/54361] Compiling for c++11 gives a warning on scanf() with %as format specifier
2012-08-23 23:34 [Bug c++/54361] New: Compiling for c++11 gives a warning on scanf() with %as format specifier strikosn at gmail dot com
2012-08-23 23:35 ` [Bug c++/54361] " strikosn at gmail dot com
@ 2012-08-23 23:54 ` jakub at gcc dot gnu.org
2012-08-24 0:04 ` strikosn at gmail dot com
2012-08-24 8:02 ` jakub at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-08-23 23:54 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54361
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-08-23 23:54:24 UTC ---
The warning is correct, %as (the oldish GNU extension) clashes with ISO C99 a
modifier for hex floats, if you want to allocate memory, use %ms instead, which
is the standard way of doing the same.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/54361] Compiling for c++11 gives a warning on scanf() with %as format specifier
2012-08-23 23:34 [Bug c++/54361] New: Compiling for c++11 gives a warning on scanf() with %as format specifier strikosn at gmail dot com
2012-08-23 23:35 ` [Bug c++/54361] " strikosn at gmail dot com
2012-08-23 23:54 ` jakub at gcc dot gnu.org
@ 2012-08-24 0:04 ` strikosn at gmail dot com
2012-08-24 8:02 ` jakub at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: strikosn at gmail dot com @ 2012-08-24 0:04 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54361
strikosn at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
--- Comment #3 from strikosn at gmail dot com 2012-08-24 00:04:39 UTC ---
Right, %ms is standardized and solves the problem. But the whole thing is
confusing because previously working C++ programs can no more compile with
-std=c++11 or -std=gnu++11, and this has nothing to do with the C++11 standard.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/54361] Compiling for c++11 gives a warning on scanf() with %as format specifier
2012-08-23 23:34 [Bug c++/54361] New: Compiling for c++11 gives a warning on scanf() with %as format specifier strikosn at gmail dot com
` (2 preceding siblings ...)
2012-08-24 0:04 ` strikosn at gmail dot com
@ 2012-08-24 8:02 ` jakub at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-08-24 8:02 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54361
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-08-24 08:02:39 UTC ---
It has a lot with C++11, if you read that standard, you'll see that for C
library stuff it refers to ISO C99 standard. Therefore, using %as is really
invalid in C++11 programs.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-08-24 8:02 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-23 23:34 [Bug c++/54361] New: Compiling for c++11 gives a warning on scanf() with %as format specifier strikosn at gmail dot com
2012-08-23 23:35 ` [Bug c++/54361] " strikosn at gmail dot com
2012-08-23 23:54 ` jakub at gcc dot gnu.org
2012-08-24 0:04 ` strikosn at gmail dot com
2012-08-24 8:02 ` jakub at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).