[Bug c/41673] New: 4.5.0 20091008 variable-length array dereference inside sizeof gives "warning: dereferencing type-punned pointer will break strict-aliasing rules"

2009-10-11 Thread gmaxwell at gmail dot com
A variable-length array pointer 'dereference' inside sizeof() is causing GCC to
give an aliasing warning. I can think of no reason why completely
compiletime-static sizeof() activity could create an aliasing violation.

I've included a contrived example showing 4.5.0 producing the warning while
4.4.1 does not complain:

[gmaxw...@floodlamp tmp]$ cat test.c
#include 
int main(int argc, char *argv[])
{
float x[argc];
float y[argc];
return NULL == memcpy(y, x, argc * sizeof(*x));
}
[gmaxw...@floodlamp tmp]$ /usr/local/bin/gcc -std=gnu99 -O2 -Wall -o test
test.c
test.c: In function ‘main’:
test.c:6:5: warning: dereferencing type-punned pointer will break
strict-aliasing rules
[gmaxw...@floodlamp tmp]$ /usr/local/bin/gcc -v
Using built-in specs.
COLLECT_GCC=/usr/local/bin/gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.5.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ./configure --with-ppl --with-cloog --with-gmp --enable-lto
Thread model: posix
gcc version 4.5.0 20091008 (experimental) (GCC) 
[gmaxw...@floodlamp tmp]$ /usr/bin/gcc -std=gnu99 -O2 -Wall -o test test.c
[gmaxw...@floodlamp tmp]$ /usr/bin/gcc -v
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla
--enable-bootstrap --enable-shared --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk
--disable-dssi --enable-plugin
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre
--enable-libgcj-multifile --enable-java-maintainer-mode
--with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib
--with-ppl --with-cloog --with-tune=generic --with-arch_32=i586
--build=x86_64-redhat-linux
Thread model: posix
gcc version 4.4.1 20090725 (Red Hat 4.4.1-2) (GCC) 

The -O2 plus sizeof(*x) anywhere where x is a var-array is necessary and
sufficient to trigger this. Switching to a statically sized array avoids the
warning.

The actual use-case where I hit this is where sizeof() is used in this manner
when a type is selected by some compile time configuration and manually
restating the type in sizeof() would require a great many more ifdefs.


-- 
   Summary: 4.5.0 20091008 variable-length array dereference inside
sizeof gives "warning: dereferencing type-punned pointer
will break strict-aliasing rules"
   Product: gcc
   Version: 4.5.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gmaxwell at gmail dot com
  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=41673



[Bug c/50286] New: Missed optimization, fails to propagate bool

2011-09-03 Thread gmaxwell at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50286

 Bug #: 50286
   Summary: Missed optimization, fails to propagate bool
Classification: Unclassified
   Product: gcc
   Version: 4.7.0
Status: UNCONFIRMED
  Severity: minor
  Priority: P3
 Component: c
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: gmaxw...@gmail.com


GCC 4.7.0 (and prior) are unable to determine maximum loop counts in code that
looks like:

#include 
int main(int argc, char **argv)
{
  int i;
  const int flag=argc>1;
  i=0;
  do{
printf("%d\n",i*i);
  }while(++i<1+flag);
  return 0;
}

and so it doesn't unroll the loop.

If 1+flag is changed to 1+!!flag, 1+(bool)flag, or 1+(argc>1) then -O3 unrolls
the loop.

Interestingly, making flag type bool doesn't fix it and also doesn't unroll in
the 1+!!flag case.


[Bug middle-end/50333] New: internal compiler error: in extract_ops_from_tree, at gimple.h:1909

2011-09-08 Thread gmaxwell at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50333

 Bug #: 50333
   Summary: internal compiler error: in extract_ops_from_tree, at
gimple.h:1909
Classification: Unclassified
   Product: gcc
   Version: 4.7.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: middle-end
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: gmaxw...@gmail.com


Created attachment 25230
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=25230
trigger case

Compiling libopus
http://git.xiph.org/?p=opus.git;a=snapshot;h=f329fa6f0f1e08506a210608bc6de34b5949ec6b;sf=tgz

libcelt/cwrs.c: In function 'encode_pulses':
libcelt/cwrs.c:589:6: internal compiler error: in extract_ops_from_tree, at
gimple.h:1909

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/home/gmaxwell/gcc/libexec/gcc/x86_64-unknown-linux-gnu/4.7.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ./configure --enable-lto --prefix=/home/gmaxwell/gcc/
--enable-cloog-backend=isl --disable-java --disable-libgcj --enable-lipo
--enable-graphite --enable-languages=c --disable-bootstrap
--enable-stage1-languages=c --disable-libstdcxx-v3
Thread model: posix
gcc version 4.7.0 20110908 (experimental) (GCC) 

CFLAGS='-O2 -ftree-vectorize' ; make

(-O3 fails too, -O2 + -ftree-vectorize seems to me the minimal failure case)

Preprocessed file attached.


[Bug middle-end/50335] New: ICE in psct_dynamic_dim, at graphite-poly.h:659

2011-09-08 Thread gmaxwell at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50335

 Bug #: 50335
   Summary: ICE in psct_dynamic_dim, at graphite-poly.h:659
Classification: Unclassified
   Product: gcc
   Version: 4.7.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: middle-end
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: gmaxw...@gmail.com


Created attachment 25231
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=25231
preprocessed case that reproduces it

Compiling libopus
http://git.xiph.org/?p=opus.git;a=snapshot;h=f329fa6f0f1e08506a210608bc6de34b5949ec6b;sf=tgz

libcelt/pitch.c: In function 'pitch_search':
libcelt/pitch.c:152:6: internal compiler error: in psct_dynamic_dim, at
graphite-poly.h:659

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/home/gmaxwell/gcc/libexec/gcc/x86_64-unknown-linux-gnu/4.7.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ./configure --enable-lto --prefix=/home/gmaxwell/gcc/
--enable-cloog-backend=isl --disable-java --disable-libgcj --enable-lipo
--enable-graphite --enable-languages=c --disable-bootstrap
--enable-stage1-languages=c --disable-libstdcxx-v3
Thread model: posix
gcc version 4.7.0 20110908 (experimental) (GCC) 

CFLAGS='-Ofast -floop-flatten' ; make

(doesn't fail with -O3 -floop-flatten)

Preprocessed file attached.


[Bug middle-end/50335] ICE in psct_dynamic_dim, at graphite-poly.h:659

2011-09-16 Thread gmaxwell at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50335

--- Comment #1 from Gregory Maxwell  2011-09-17 
00:31:43 UTC ---
Still failing in r178925.


[Bug middle-end/50335] ICE in psct_dynamic_dim, at graphite-poly.h:659

2011-10-07 Thread gmaxwell at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50335

--- Comment #2 from Gregory Maxwell  2011-10-07 
14:52:37 UTC ---
Still failing in r179659.


[Bug middle-end/50335] ICE in psct_dynamic_dim, at graphite-poly.h:659

2011-10-07 Thread gmaxwell at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50335

--- Comment #4 from Gregory Maxwell  2011-10-07 
15:29:42 UTC ---
Ha, indeed. Well, I don't want it to be forgotten just because its become old
and potentially inapplicable.

I test GCC development periodically on all the software I work on— most of the
time anything I find is fixed quickly, it's not something urgent for me. (I
once reported a bug in a proprietary compiler: reporting bugs in GCC is my
penance ;) )


[Bug middle-end/50335] ICE in psct_dynamic_dim, at graphite-poly.h:659

2012-02-14 Thread gmaxwell at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50335

--- Comment #11 from Gregory Maxwell  2012-02-14 
17:15:23 UTC ---
Still crashing in, r184217.


[Bug middle-end/50335] ICE in psct_dynamic_dim, at graphite-poly.h:659

2012-02-22 Thread gmaxwell at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50335

--- Comment #12 from Gregory Maxwell  2012-02-22 
09:19:54 UTC ---
_Not_ failing in r184458.  Perhaps fixed by r184265?


[Bug middle-end/50335] ICE in psct_dynamic_dim, at graphite-poly.h:659

2012-02-22 Thread gmaxwell at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50335

--- Comment #13 from Gregory Maxwell  2012-02-22 
09:39:51 UTC ---
Okay, it doesn't ICE now— but now I have cases where it apparently runs forever
and cases where it produces incorrect code with -floop-flatten.


[Bug middle-end/50335] ICE in psct_dynamic_dim, at graphite-poly.h:659

2011-11-13 Thread gmaxwell at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50335

--- Comment #5 from Gregory Maxwell  2011-11-14 
06:19:44 UTC ---
Still failing with r181345


[Bug middle-end/50335] ICE in psct_dynamic_dim, at graphite-poly.h:659

2011-12-05 Thread gmaxwell at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50335

--- Comment #6 from Gregory Maxwell  2011-12-06 
04:51:47 UTC ---
Still failing in r182038