This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/17665] wrong code with -O2
- From: "davids at webmaster dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 25 Sep 2004 17:35:20 -0000
- Subject: [Bug c/17665] wrong code with -O2
- References: <20040924231306.17665.davids@webmaster.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From davids at webmaster dot com 2004-09-25 17:35 -------
(In reply to comment #4)
> The problematic object types in your code are "void *" and "char *"
> (accessed by dereferencing "void **" and "char **" pointers), not "void"
> and "char".
This is legal C and C++. The *only* use for 'void *' is to alias something. If
it was 'char *' and 'int *', I'd 100% agree with you. However, you are
specifically permitted to alias 'void *'.
Other than returning NULL or using it in a union, there is nothing you can do
with 'void *' other than to use it to hold the same thing as some other type.
A pointer to a void is not actually a pointer to a void, it's a generic pointer
type. Its typical use, defined by the standard, is to cast other types through
it.
Unless you can explain how my use of 'void *' differs from the types
specifically permitted by the standard, calling this bug report invalid is
equivalent to saying you can't use 'void *' without defining -fno-strict-
aliasing.
Basically, what I'm saying is that because the standard specifically allows
(and precisely defined the affects of) casting other pointer types to 'void *',
the compiler should not assume that a 'void *' isn't an alias of another type,
thought it is entirely justified in doing so for other types.
DS
--
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|INVALID |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17665