* C++: fix sizeof null deref warning
@ 2004-07-09 2:17 Mike Stump
2004-07-09 7:14 ` Mark Mitchell
2004-07-09 16:28 ` Jason Merrill
0 siblings, 2 replies; 3+ messages in thread
From: Mike Stump @ 2004-07-09 2:17 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 208 bytes --]
We give a warning for the testcase below, but that is wrong, the patch
fixes it.
class Foo {
int children[4];
public:
unsigned function(void) {
return sizeof (((Foo*)0)->children);
}
};
Ok?
[-- Attachment #2: sizeofnullderef.diffs.txt --]
[-- Type: text/plain, Size: 1398 bytes --]
2004-07-08 Mike Stump <mrs@apple.com>
* typeck.c (build_class_member_access_expr): Skip null deref
warning when we don't dereference it.
Doing diffs in .:
*** ./cp/typeck.c.~1~ Wed Jul 7 17:09:18 2004
--- ./cp/typeck.c Thu Jul 8 14:57:22 2004
*************** build_class_member_access_expr (tree obj
*** 1707,1713 ****
actually used the offsetof macro, since there's no way to know at this
point. So we just give a warning, instead of a pedwarn. */
if (null_object_p && warn_invalid_offsetof
! && CLASSTYPE_NON_POD_P (object_type))
{
warning ("invalid access to non-static data member `%D' of NULL object",
member);
--- 1707,1714 ----
actually used the offsetof macro, since there's no way to know at this
point. So we just give a warning, instead of a pedwarn. */
if (null_object_p && warn_invalid_offsetof
! && CLASSTYPE_NON_POD_P (object_type)
! && ! skip_evaluation)
{
warning ("invalid access to non-static data member `%D' of NULL object",
member);
*** ./testsuite/g++.old-deja/g++.mike/sizeof.C.~1~ Thu Jul 8 17:30:13 2004
--- ./testsuite/g++.old-deja/g++.mike/sizeof.C Thu Jul 8 14:58:47 2004
***************
*** 0 ****
--- 1,9 ----
+ // { dg-do compile }
+
+ class Foo {
+ int children[4];
+ public:
+ unsigned function(void) {
+ return sizeof (((Foo*)0)->children);
+ }
+ };
--------------
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: C++: fix sizeof null deref warning
2004-07-09 2:17 C++: fix sizeof null deref warning Mike Stump
@ 2004-07-09 7:14 ` Mark Mitchell
2004-07-09 16:28 ` Jason Merrill
1 sibling, 0 replies; 3+ messages in thread
From: Mark Mitchell @ 2004-07-09 7:14 UTC (permalink / raw)
To: Mike Stump; +Cc: gcc-patches
Mike Stump wrote:
> We give a warning for the testcase below, but that is wrong, the patch
> fixes it.
OK.
--
Mark Mitchell
CodeSourcery, LLC
(916) 791-8304
mark@codesourcery.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: C++: fix sizeof null deref warning
2004-07-09 2:17 C++: fix sizeof null deref warning Mike Stump
2004-07-09 7:14 ` Mark Mitchell
@ 2004-07-09 16:28 ` Jason Merrill
1 sibling, 0 replies; 3+ messages in thread
From: Jason Merrill @ 2004-07-09 16:28 UTC (permalink / raw)
To: Mike Stump; +Cc: gcc-patches
OK.
Jason
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-07-09 15:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-09 2:17 C++: fix sizeof null deref warning Mike Stump
2004-07-09 7:14 ` Mark Mitchell
2004-07-09 16:28 ` Jason Merrill
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).