[Bug c++/36149] -O2 optimization generates wrong code

2008-05-11 Thread pinskia at gcc dot gnu dot org


-- 

pinskia at gcc dot gnu dot org changed:

   What|Removed |Added

   Severity|major   |normal
 Status|UNCONFIRMED |WAITING
   Keywords||alias, wrong-code


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



[Bug c++/36149] -O2 optimization generates wrong code

2008-05-07 Thread dino at concisoft dot com


--- Comment #9 from dino at concisoft dot com  2008-05-07 06:15 ---
Understood. Just haven't been able to reproduce on a small piece of code :-(

It seems GNU C++ compiler doesn't give strict-aliasing warnings.


-- 


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



[Bug c++/36149] -O2 optimization generates wrong code

2008-05-07 Thread rguenth at gcc dot gnu dot org


--- Comment #10 from rguenth at gcc dot gnu dot org  2008-05-07 19:29 
---
Note that gcc 4.1 is known to have some wrong-code bugs regarding aliasing.


-- 


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



[Bug c++/36149] -O2 optimization generates wrong code

2008-05-06 Thread dino at concisoft dot com


--- Comment #1 from dino at concisoft dot com  2008-05-06 07:19 ---
The same code works fine with -O1 and -O3.


-- 


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



[Bug c++/36149] -O2 optimization generates wrong code

2008-05-06 Thread pinskia at gcc dot gnu dot org


--- Comment #2 from pinskia at gcc dot gnu dot org  2008-05-06 08:23 ---
How is LC defined?


-- 


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



[Bug c++/36149] -O2 optimization generates wrong code

2008-05-06 Thread dino at concisoft dot com


--- Comment #3 from dino at concisoft dot com  2008-05-06 14:18 ---
templateclass Y static LINK* LC(Y* X) {
return static_castLINK*(X);
}
templateclass Y static const LINK* LCC(Y* X) {
return static_castconst LINK*(X);
}


-- 


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



[Bug c++/36149] -O2 optimization generates wrong code

2008-05-06 Thread pinskia at gcc dot gnu dot org


--- Comment #4 from pinskia at gcc dot gnu dot org  2008-05-06 15:23 ---
This looks like you are violating C/C++ aliasing rules from that definition.


-- 


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



[Bug c++/36149] -O2 optimization generates wrong code

2008-05-06 Thread dino at concisoft dot com


--- Comment #5 from dino at concisoft dot com  2008-05-06 15:42 ---
Are we missing a const, or would you care to give a bit more specific comment?

I see that:

templateclass Y static const LINK* LCC(Y* X) {
return static_castconst LINK*(X);
}

could be missing a const in the declaration of Y* X, should probably be const
Y* X. Is that what you're referring to?


-- 


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



[Bug c++/36149] -O2 optimization generates wrong code

2008-05-06 Thread pinskia at gcc dot gnu dot org


--- Comment #6 from pinskia at gcc dot gnu dot org  2008-05-06 15:45 ---
As I mentioned it looks like you are violating aliasing rules.  Basically you
are accessing one type as another.  But without a full testcase I cann't be
sure.  Also Does -O2 -fno-strict-aliasing work?


-- 


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



[Bug c++/36149] -O2 optimization generates wrong code

2008-05-06 Thread dino at concisoft dot com


--- Comment #7 from dino at concisoft dot com  2008-05-06 16:54 ---
-O2 -fno-strict-aliasing does work.

I think the LC and LLC functions always cast from a derived class to a base
class. That shouldn't cause aliasing problems, but I need to learn more about
that.

Thanks.


-- 


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



[Bug c++/36149] -O2 optimization generates wrong code

2008-05-06 Thread bangerth at dealii dot org


--- Comment #8 from bangerth at dealii dot org  2008-05-07 04:17 ---
The point is: without the complete source code nothing definitive can
be said whether it's the compiler's or the programmer's fault. Your chances
that someone will take the time to try to understand what's going on
increase exponentially if you manage to produce a small testcase, whereas
they are pretty low if all you can show is several thousand lines of code.

W.


-- 

bangerth at dealii dot org changed:

   What|Removed |Added

 CC||bangerth at dealii dot org


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