public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/19542] New: attribute(sentinel) has problems with C++ __null
@ 2005-01-20 9:52 marcus at jet dot franken dot de
2005-01-20 9:53 ` [Bug c++/19542] " marcus at jet dot franken dot de
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: marcus at jet dot franken dot de @ 2005-01-20 9:52 UTC (permalink / raw)
To: gcc-bugs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 819 bytes --]
when using __attribute__((__sentinel__)) with the C++ NULL defined
as __null, a sentinel warning is still triggered.
Attached testcase gives:
g++ -c xx.cc -Wall
xx.cc: In function âvoid g()â:
xx.cc:5: warning: missing sentinel in function call
--
Summary: attribute(sentinel) has problems with C++ __null
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: marcus at jet dot franken dot de
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19542
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/19542] attribute(sentinel) has problems with C++ __null
2005-01-20 9:52 [Bug c++/19542] New: attribute(sentinel) has problems with C++ __null marcus at jet dot franken dot de
@ 2005-01-20 9:53 ` marcus at jet dot franken dot de
2005-01-20 13:11 ` giovannibajo at libero dot it
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: marcus at jet dot franken dot de @ 2005-01-20 9:53 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From marcus at jet dot franken dot de 2005-01-20 09:52 -------
Created an attachment (id=8003)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=8003&action=view)
xx.cc
testcse, compile with -Wall
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19542
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/19542] attribute(sentinel) has problems with C++ __null
2005-01-20 9:52 [Bug c++/19542] New: attribute(sentinel) has problems with C++ __null marcus at jet dot franken dot de
2005-01-20 9:53 ` [Bug c++/19542] " marcus at jet dot franken dot de
@ 2005-01-20 13:11 ` giovannibajo at libero dot it
2005-01-20 13:44 ` marcus at jet dot franken dot de
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: giovannibajo at libero dot it @ 2005-01-20 13:11 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From giovannibajo at libero dot it 2005-01-20 13:11 -------
__null is 0 of integer type, while attribute sentinel checks for 0 of pointer
type. Remember this is not the same because it depends on the ABI: on some
platforms, pushing a 0 of integer type into the stack for a call is different
from pushing a 0 of pointer type. In fact, using __null for (eg) concat() is
actually a real bug.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19542
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/19542] attribute(sentinel) has problems with C++ __null
2005-01-20 9:52 [Bug c++/19542] New: attribute(sentinel) has problems with C++ __null marcus at jet dot franken dot de
2005-01-20 9:53 ` [Bug c++/19542] " marcus at jet dot franken dot de
2005-01-20 13:11 ` giovannibajo at libero dot it
@ 2005-01-20 13:44 ` marcus at jet dot franken dot de
2005-01-20 15:00 ` pinskia at gcc dot gnu dot org
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: marcus at jet dot franken dot de @ 2005-01-20 13:44 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From marcus at jet dot franken dot de 2005-01-20 13:44 -------
well, i am not specifying the NULL, the code actually has "NULL".
However it gets defined by the gcc stdef.h file:
#if defined (_STDDEF_H) || defined (__need_NULL)
#undef NULL /* in case <stdio.h> has defined it. */
#ifdef __GNUG__
#define NULL __null
#else /* G++ */
#ifndef __cplusplus
#define NULL ((void *)0)
#else /* C++ */
#define NULL 0
#endif /* C++ */
#endif /* G++ */
#endif /* NULL not defined and <stddef.h> or need NULL. */
#undef __need_NULL
So:
- is gcc wrong?
- should the code always use (type*)NULL in such vararg lists?
--
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|INVALID |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19542
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/19542] attribute(sentinel) has problems with C++ __null
2005-01-20 9:52 [Bug c++/19542] New: attribute(sentinel) has problems with C++ __null marcus at jet dot franken dot de
` (2 preceding siblings ...)
2005-01-20 13:44 ` marcus at jet dot franken dot de
@ 2005-01-20 15:00 ` pinskia at gcc dot gnu dot org
2005-01-20 15:05 ` marcus at jet dot franken dot de
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-01-20 15:00 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-01-20 15:00 -------
C++ is differrent from C.
NULL in C++ is defined special in that it is defined as an int but C is different. You should always use a
cast when you passing to a varargs otherwise you might get a problem on 64bit targets and otherwise.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19542
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/19542] attribute(sentinel) has problems with C++ __null
2005-01-20 9:52 [Bug c++/19542] New: attribute(sentinel) has problems with C++ __null marcus at jet dot franken dot de
` (3 preceding siblings ...)
2005-01-20 15:00 ` pinskia at gcc dot gnu dot org
@ 2005-01-20 15:05 ` marcus at jet dot franken dot de
2005-01-20 15:35 ` matz at suse dot de
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: marcus at jet dot franken dot de @ 2005-01-20 15:05 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From marcus at jet dot franken dot de 2005-01-20 15:05 -------
thanks!
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19542
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/19542] attribute(sentinel) has problems with C++ __null
2005-01-20 9:52 [Bug c++/19542] New: attribute(sentinel) has problems with C++ __null marcus at jet dot franken dot de
` (4 preceding siblings ...)
2005-01-20 15:05 ` marcus at jet dot franken dot de
@ 2005-01-20 15:35 ` matz at suse dot de
2005-05-01 1:13 ` cvs-commit at gcc dot gnu dot org
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: matz at suse dot de @ 2005-01-20 15:35 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From matz at suse dot de 2005-01-20 15:35 -------
I agree that C++ is special, and that NULL in C++ is only a null pointer
constant (but not a null pointer). Hence, yes, strictly speaking a cast
would be needed even for NULL in va_lists.
But, as a matter of fact, GCC defines __null as an integer node having value
zero, and type exactly as wide as a pointer would be (i.e. somewhat
similar to 0L). So, giving this to a va_list, which expects a pointer
would work correctly, also on LP64 platforms. This is the reason for the
existance of __null (as otherwise we could simply define NULL to "0" and
still be completely standard conformant). This suggests that those
who implemented __null did it because they wanted to enable its use
in situations where in C a lonely "NULL" is enough.
As a QOI issue it would be better if this warning wouldn't trigger for this
use. In our packages it triggers quite often in C++ code, most of them
being false positives. That's in difference to C, where most of these
warnings indeed are problems for LP64 platforms.
I believe (but haven't verified) that the warning could additionally check
for the node being == null_node, and not warn in this case. This wouldn't
make the warning less usefull AFAICS, and for C++ would reduce the number
of false positives.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19542
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/19542] attribute(sentinel) has problems with C++ __null
2005-01-20 9:52 [Bug c++/19542] New: attribute(sentinel) has problems with C++ __null marcus at jet dot franken dot de
` (5 preceding siblings ...)
2005-01-20 15:35 ` matz at suse dot de
@ 2005-05-01 1:13 ` cvs-commit at gcc dot gnu dot org
2005-05-01 3:39 ` pinskia at gcc dot gnu dot org
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-05-01 1:13 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2005-05-01 01:13 -------
Subject: Bug 19542
CVSROOT: /cvs/gcc
Module name: gcc
Branch: gcc-4_0-branch
Changes by: matz@gcc.gnu.org 2005-05-01 01:13:09
Modified files:
gcc : c-common.h c-opts.c c.opt c-common.c ChangeLog
gcc/doc : invoke.texi
gcc/cp : cp-tree.h lex.c ChangeLog
gcc/testsuite : ChangeLog
Added files:
gcc/testsuite/g++.dg/warn: sentinel.C
Log message:
ChangeLog:
PR c++/19542
* c-common.c (c_common_nodes_and_builtins): Create global null_node.
(warn_strict_null_sentinel): Define.
(check_function_sentinel): Check for null_node as valid sentinel too.
* c-common.h (c_tree_index): Added CTI_NULL.
(null_node) Define global_tree[CTI_NULL].
(warn_strict_null_sentinel): Declare.
* c-opts.c: (c_common_handle_option): Handle -Wstrict-null-sentinel.
* c.opt: (Wstrict-null-sentinel): New C++ option.
* doc/invoke.texi (C++ Options): Document -Wstrict-null-sentinel.
cp/ChangeLog:
PR c++/19542
* cp-tree.h (cp_tree_index): Remove CPTI_NULL, to be defined in C
common frontend.
(null_node): Remove.
* lex.c (cxx_init): Move null_node initialisation to C common frontend.
testsuite/ChangeLog:
PR c++/19542
* g++.dg/warn/sentinel.C: New testcase for __null sentinels added.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-common.h.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.277.2.1&r2=1.277.2.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-opts.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.136.2.2&r2=1.136.2.3
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c.opt.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.34.8.3&r2=1.34.8.4
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-common.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.606.2.2&r2=1.606.2.3
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=2.7592.2.207&r2=2.7592.2.208
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/doc/invoke.texi.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.583.2.15&r2=1.583.2.16
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.h.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.1106.2.3&r2=1.1106.2.4
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/lex.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.353&r2=1.353.12.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.4648.2.36&r2=1.4648.2.37
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/warn/sentinel.C.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.5084.2.151&r2=1.5084.2.152
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19542
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/19542] attribute(sentinel) has problems with C++ __null
2005-01-20 9:52 [Bug c++/19542] New: attribute(sentinel) has problems with C++ __null marcus at jet dot franken dot de
` (7 preceding siblings ...)
2005-05-01 3:39 ` pinskia at gcc dot gnu dot org
@ 2005-05-01 3:39 ` pinskia at gcc dot gnu dot org
2005-05-02 4:23 ` cvs-commit at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-05-01 3:39 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-05-01 03:39 -------
Reopening to ..
--
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|INVALID |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19542
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/19542] attribute(sentinel) has problems with C++ __null
2005-01-20 9:52 [Bug c++/19542] New: attribute(sentinel) has problems with C++ __null marcus at jet dot franken dot de
` (6 preceding siblings ...)
2005-05-01 1:13 ` cvs-commit at gcc dot gnu dot org
@ 2005-05-01 3:39 ` pinskia at gcc dot gnu dot org
2005-05-01 3:39 ` pinskia at gcc dot gnu dot org
2005-05-02 4:23 ` cvs-commit at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-05-01 3:39 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-05-01 03:39 -------
To Mark as a dup of bug 18886.
*** This bug has been marked as a duplicate of 18886 ***
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |DUPLICATE
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19542
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/19542] attribute(sentinel) has problems with C++ __null
2005-01-20 9:52 [Bug c++/19542] New: attribute(sentinel) has problems with C++ __null marcus at jet dot franken dot de
` (8 preceding siblings ...)
2005-05-01 3:39 ` pinskia at gcc dot gnu dot org
@ 2005-05-02 4:23 ` cvs-commit at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-05-02 4:23 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2005-05-02 04:23 -------
Subject: Bug 19542
CVSROOT: /cvs/gcc
Module name: gcc
Changes by: matz@gcc.gnu.org 2005-05-02 04:22:57
Modified files:
gcc : c-common.c c-common.h c-opts.c c.opt ChangeLog
gcc/doc : invoke.texi
gcc/cp : cp-tree.h lex.c ChangeLog
gcc/testsuite : ChangeLog
Added files:
gcc/testsuite/g++.dg/warn: sentinel.C
Log message:
PR c++/19542
* c-common.c (c_common_nodes_and_builtins): Create global null_node.
(warn_strict_null_sentinel): Define.
(check_function_sentinel): Check for null_node as valid sentinel too.
* c-common.h (c_tree_index): Added CTI_NULL.
(null_node) Define global_tree[CTI_NULL].
(warn_strict_null_sentinel): Declare.
* c-opts.c: (c_common_handle_option): Handle -Wstrict-null-sentinel.
* c.opt: (Wstrict-null-sentinel): New C++ option.
* doc/invoke.texi (C++ Options): Document -Wstrict-null-sentinel.
* cp-tree.h (cp_tree_index): Remove CPTI_NULL, to be defined in C
common frontend.
(null_node): Remove.
* lex.c (cxx_init): Move null_node initialisation to C common frontend.
* g++.dg/warn/sentinel.C: New testcase for __null sentinels added.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-common.c.diff?cvsroot=gcc&r1=1.625&r2=1.626
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-common.h.diff?cvsroot=gcc&r1=1.288&r2=1.289
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-opts.c.diff?cvsroot=gcc&r1=1.142&r2=1.143
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c.opt.diff?cvsroot=gcc&r1=1.41&r2=1.42
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.8553&r2=2.8554
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/doc/invoke.texi.diff?cvsroot=gcc&r1=1.610&r2=1.611
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.h.diff?cvsroot=gcc&r1=1.1131&r2=1.1132
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/lex.c.diff?cvsroot=gcc&r1=1.355&r2=1.356
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4724&r2=1.4725
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/warn/sentinel.C.diff?cvsroot=gcc&r1=1.1&r2=1.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5423&r2=1.5424
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19542
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2005-05-02 4:23 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-20 9:52 [Bug c++/19542] New: attribute(sentinel) has problems with C++ __null marcus at jet dot franken dot de
2005-01-20 9:53 ` [Bug c++/19542] " marcus at jet dot franken dot de
2005-01-20 13:11 ` giovannibajo at libero dot it
2005-01-20 13:44 ` marcus at jet dot franken dot de
2005-01-20 15:00 ` pinskia at gcc dot gnu dot org
2005-01-20 15:05 ` marcus at jet dot franken dot de
2005-01-20 15:35 ` matz at suse dot de
2005-05-01 1:13 ` cvs-commit at gcc dot gnu dot org
2005-05-01 3:39 ` pinskia at gcc dot gnu dot org
2005-05-01 3:39 ` pinskia at gcc dot gnu dot org
2005-05-02 4:23 ` cvs-commit at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).