This is the mail archive of the gcc-patches@gcc.gnu.org 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]

Re: [c++] warn if NULL is passed through varargs


Michael Matz <matz@suse.de> writes:

| Hi,
| 
| On 10 Oct 2002, Gabriel Dos Reis wrote:
| 
| > | > to the intended pointer type in C, just like it currently does in C++
| > | > (except in the varargs case, that the patch fixes).
| > | >
| > | > Which of these arguments do you disagree with?  Or, which
| > | > counter-arguments can you bring into this debate?
| > |
| > | Real world?  Which machine which is supported by gcc has a different
| > | representation of different pointer types (in C please).
| >
| > an LP64 machine where you have sizeof 0 == 32 and sizeof(void*) == 64?
| 
| I asked about different _pointer_ types.

Sorry, I misread that part.  See below

| > As pointed out by Alexandre, because GCC defines NULL to be (void*)0
| > in C, you won't see the problem.
| 
| That was my point, exactly.

As it happens however in practice, GCC already has warning switches
for *portability* purpose, and the proposed switch is exactly one that
aims to promote portability.  OR are you saying that GCC should get
rid of portability switches

| > But with a compiler that unconditionally defines it to be plain 0, you
| > get a problem.
| 
| A compiler (or library header) which defines NULL for C (which has to be a
| pointer)

Wrong -- NULL in C is *not* required to be a pointer.

| to just 0 on such a machine is broken.  It either has to use
| (void*)0, or 0L, or similar stuff (or a compiler builtin).  Also, I asked
| about the real world ;-)  _Is_ there actually such a machine with such
| headers, supported by gcc?  

Your question is irrevelant to the issue as the issue isn't about two
different representations of pointer but differences in 
_*int* and *pointer*_ representations.

-- Gaby


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