[Bug other/12315] [3.4 Regression] ICE using -p with functions returning structs
PLEASE REPLY TO [EMAIL PROTECTED] ONLY, *NOT* [EMAIL PROTECTED] http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12315 pinskia at gcc dot gnu dot org changed: What|Removed |Added CC||msk at tepkom dot ru --- Additional Comments From pinskia at gcc dot gnu dot org 2003-10-30 06:21 --- *** Bug 12836 has been marked as a duplicate of this bug. *** --- You are receiving this mail because: --- You are on the CC list for the bug, or are watching someone who is.
[Bug other/12315] [3.4 Regression] ICE using -p with functions returning structs
PLEASE REPLY TO [EMAIL PROTECTED] ONLY, *NOT* [EMAIL PROTECTED] http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12315 pinskia at gcc dot gnu dot org changed: What|Removed |Added CC||amodra at bigpond dot net ||dot au AssignedTo|unassigned at gcc dot gnu |dj at redhat dot com |dot org | Status|NEW |ASSIGNED --- Additional Comments From pinskia at gcc dot gnu dot org 2003-10-30 06:26 --- DJ, your patch is known to work, see Alan Modra's patch which really the same patch. --- You are receiving this mail because: --- You are on the CC list for the bug, or are watching someone who is.
Bug#217360: gcc-3.2: meaningless warning for %p in format strings
Falk Hueffner wrote: Jason Kraftcheck <[EMAIL PROTECTED]> writes: If the following is compiled with the options -Wall -pedantic-errors : #include int main( ) { int i; printf("%p\n", &i ); return 0; } gcc emits the following: voidptr.c: In function `main': voidptr.c:5: warning: void format, different type arg (arg 2) This warning is meaningless. The type of the pointer doesn't matter for printf to write out the address. According to the C standard, it does. And you specifically asked for gcc to be pedantic. The C standard says there's a difference between printing a void* and a int* (or any other type)? How can a pointer passed through a var-args list be anything but a void*? The C standard may say that %p prints a void*, but isn't any pointer passed through a var-args a void*? An implicit cast to a void* doesn't generate a warning under other circumstances. Neither do other implicit casts in var-args lists. The following compiled with '-Wall -pedantic-errors" does not result in any warnings: int main() { float f; memset( &f, 0, sizeof(f)); /* implicit cast to void* */ printf("%f\n", f); /* promotion from float to double */ return 0; }
Bug#217360: gcc-3.2: meaningless warning for %p in format strings
Jason Kraftcheck <[EMAIL PROTECTED]> writes: > The C standard says there's a difference between printing a void* > and a int* (or any other type)? How can a pointer passed through a > var-args list be anything but a void*? The C standard may say that > %p prints a void*, but isn't any pointer passed through a var-args a > void*? I don't see that anywhere in the standard. As I see it, only the default argument conversions are executed, which does not include this conversion. -- Falk
Bug#217360: gcc-3.2: meaningless warning for %p in format strings
Falk Hueffner wrote: Jason Kraftcheck <[EMAIL PROTECTED]> writes: The C standard says there's a difference between printing a void* and a int* (or any other type)? How can a pointer passed through a var-args list be anything but a void*? The C standard may say that %p prints a void*, but isn't any pointer passed through a var-args a void*? I don't see that anywhere in the standard. As I see it, only the default argument conversions are executed, which does not include this conversion. In practice, how can it be anything other than a void*? Anyway, the warning is meaningless regardless. Changing printf("%p\n", &i); to printf("%p\n", (void*)(&i)); makes the warning go away. There is no case where such a cast can possibly make any difference in the output. For situations where casts can actually change the value of a pointer (e.g. C++ objects), void* is the one case where that is guaranteed not to happen. The warning is useless noise. Or am I missing something fundamental here?
Bug#217360: gcc-3.2: meaningless warning for %p in format strings
Jason Kraftcheck <[EMAIL PROTECTED]> writes: > In practice, how can it be anything other than a void*? It can't. You know, the "-pedantic" option is called "-pedantic" for a reason. It doesn't make a difference on any existing gcc platform, but it would be possible to cnstruct a C99-compliant environment where it doesn't. -- Falk
Bug#217360: gcc-3.2: meaningless warning for %p in format strings
Falk Hueffner wrote: Jason Kraftcheck <[EMAIL PROTECTED]> writes: In practice, how can it be anything other than a void*? It can't. You know, the "-pedantic" option is called "-pedantic" for a Yes, but there's a difference between pedantic and pointless. Although you've convinced me it is the former. reason. It doesn't make a difference on any existing gcc platform, but it would be possible to cnstruct a C99-compliant environment where it [does]. I hadn't considered an environment where void* and some other pointer type (e.g. char* on a word-addressable machine) would actually have a different binary representation when pointing to the same memory.