This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/25173] gcc outputs unnecessary warnings

------- Comment #2 from jw203198 at hotmail dot com  2005-11-30 02:07 -------
But surely that example isn't evidence of a problem.

Because if somebody codes:

     int *p = f();

does it really matter what the signedness of f()'s return value is?
The caller has a pointer which is most definitely "int *" and that is obviously
what the caller wants. We all know (I hope) that the difference between an "int
*" and "unsigned int *" only becomes apparent when the pointer is dereferenced.

The caller wants an "int *".  Unfortunately the writer of f() has to make some
choice between signed/unsigned and invariably his choice will be wrong 50% of
the time because the writer of f() often doesn't really care what sort of data
is stored at the pointer's target location.

My assertion still stands.  It doesn't matter what the signedness of a pointer
is until it is actually dereferenced.  And at that point the programmer who is
writing the code which involves pointer dereferencing really does know exactly
what the consequences are.  It doesn't matter what the pointer signedness is
through all those other functions which just pass pointers around without
dereferencing them.


jw203198 at hotmail dot com changed:

           What    |Removed                     |Added
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]