[Bug c++/54361] New: Compiling for c++11 gives a warning on scanf() with %as format specifier

2012-08-23 Thread strikosn at gmail dot com
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: unassig...@gcc.gnu.org
ReportedBy: strik...@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


[Bug c++/54361] Compiling for c++11 gives a warning on scanf() with %as format specifier

2012-08-23 Thread strikosn at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54361

--- Comment #1 from Nick Strikos  2012-08-23 
23:35:31 UTC ---
Created attachment 28075
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28075
Testcase


[Bug c++/54361] Compiling for c++11 gives a warning on scanf() with %as format specifier

2012-08-23 Thread strikosn at gmail dot com
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.


[Bug c++/54441] New: Infinite loop with brace initializer on zero-length array

2012-08-31 Thread strikosn at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54441

 Bug #: 54441
   Summary: Infinite loop with brace initializer on zero-length
array
Classification: Unclassified
   Product: gcc
   Version: 4.7.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: strik...@gmail.com


Consider this:

struct s { char c[]; };

int main()
{
struct s s = { .c = 0 };
return 0;
}

Compiling with 'g++ -Wall h.c' gives infinite warnings:

h.c: In function 'int main()':
h.c:5:24: warning: missing braces around initializer for 'char [0]'
[-Wmissing-braces]
h.c:5:24: warning: missing braces around initializer for 'char [0]'
[-Wmissing-braces]
h.c:5:24: warning: missing braces around initializer for 'char [0]'
[-Wmissing-braces]
h.c:5:24: warning: missing braces around initializer for 'char [0]'
[-Wmissing-braces]
...

Version: GNU C++ (GCC) version 4.7.0
Target: x86_64-unknown-linux-gnu


[Bug c/45320] New: Strict-aliasing misdetection

2010-08-18 Thread strikosn at gmail dot com
The following code fails to detect breaking of strict-aliasing rules correctly:

#include 

int main()
{
int i;
float A[20];

for (i = 0; i < 20; i++)
{   
A[i] = i;
unsigned int *p = (unsigned int *)&A[i];
printf("%d\t%.24f\t0x%08x\n", i, A[i], *p);
}

return 0;
}

gcc only gives a warning when compiling with '-Wall -O1'. Yet, compiling with
'-Wall -fstrict-aliasing' seems to produce correct results, even though '-Wall
-O2' breaks the code.


-- 
   Summary: Strict-aliasing misdetection
   Product: gcc
   Version: 4.4.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: strikosn at gmail dot com
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45320



[Bug c/45320] Strict-aliasing misdetection

2010-08-19 Thread strikosn at gmail dot com


--- Comment #3 from strikosn at gmail dot com  2010-08-19 09:50 ---
Ok, I reviewed all cases and it seems that gcc always does the right thing. The
only problem left is that strict-aliasing warning Levels 2 and 3, of which
Level 3 is enabled by default, do not detect this particular case of
strict-aliasing, even though Level 1 detects it correctly.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45320