--- Comment #14 from joseph at codesourcery dot com 2008-11-30 15:37
---
Subject: Re: O2 causes invalid code
On Sun, 30 Nov 2008, rguenth at gcc dot gnu dot org wrote:
> Note that the C standard forbids type-punning through a union.
> Basically it says that you may only read from a
--- Comment #13 from rguenth at gcc dot gnu dot org 2008-11-30 11:43
---
Note that the C standard forbids type-punning through a union. Basically it
says
that you may only read from a union member if you have previously written to
it.
It also says that all other bits apart from the one
--- Comment #12 from cdfrey at netdirect dot ca 2008-11-28 23:36 ---
> The reason why the union case is considered
> unspecified is because it depends on the under
> laying bit representation of float.
That makes sense. In this case, it's not really a type punning issue and more
of a f
--- Comment #11 from pinskia at gcc dot gnu dot org 2008-11-28 23:32
---
There is no way currently inside the code to figure out if the C/C++ aliasing
rules are activated or not. And I hope there will never be a way because it is
better to fix up your code. The reason why the union ca
--- Comment #10 from andrew at warnux dot com 2008-11-28 22:02 ---
The shortest answer possible will be fine. I don't want to be an annoyance.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38297
--- Comment #9 from andrew at warnux dot com 2008-11-28 22:01 ---
I have another question. I want to be able to detect if fno-strict-aliasing
was used when compiling. Preferably at compile time but run time will be fine.
How can I do this?
--
andrew at warnux dot com changed:
--- Comment #8 from cdfrey at netdirect dot ca 2008-11-28 19:24 ---
Why is the union access not portable, and listed as a GCC extension?
According to the quotation of the standard at:
http://mail-index.netbsd.org/tech-kern/2003/08/11/0001.html
(this link is found in the GCC docs on this
--- Comment #7 from pinskia at gcc dot gnu dot org 2008-11-28 16:52 ---
1) Yes that is the reason why -Wstrict-aliasing exist. This is undefined
behavior at runtime not at compile time so we cannot error out. It is also the
reason why -Wstrict-aliasing is enabled with -Wall.
2) Use me
--- Comment #6 from andrew at warnux dot com 2008-11-28 16:38 ---
I do have a couple concerns:
1. This one is MAJOR. Without using -Wstrict-aliasing, I never see warnings
about this change. I can't even begin to explain how bad that is. The gcc
programmers made a big change (that is
--- Comment #5 from andrew at warnux dot com 2008-11-28 02:33 ---
Thanks! I guess I learned something new today.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38297
--- Comment #4 from pinskia at gcc dot gnu dot org 2008-11-28 02:20 ---
Yep you are violating C++ aliasing rules as you are accessing a char * as an
unsigned char*. It would be ok if you accessed a char as an unsigned char but
you are accessing the pointers instead.
It is not the size
--- Comment #3 from andrew at warnux dot com 2008-11-28 01:59 ---
unsigned char
char and byte are the same size (1 byte), so why is there a problem?
--
andrew at warnux dot com changed:
What|Removed |Added
-
--- Comment #2 from pinskia at gcc dot gnu dot org 2008-11-28 01:38 ---
What is byte typedef? Is it unsigned char or signed char? If so then you are
violating aliasing rules by modifying a char* via that pointer type. Yes
char/unsigned char/signed char are special but their pointer ty
--- Comment #1 from andrew at warnux dot com 2008-11-28 00:32 ---
I guess you want this too:
gcc -v
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.3.2-1ubuntu11'
--with-bugurl=file:///usr/share/doc/gcc-4.3/README.Bugs
--en
14 matches
Mail list logo