public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/aoliva/heads/testme)] hash set: reject attempts to insert null pointers
@ 2022-12-23 7:31 Alexandre Oliva
0 siblings, 0 replies; 3+ messages in thread
From: Alexandre Oliva @ 2022-12-23 7:31 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:3634f8ee967c3adb60efc759f9aca885b83ba2bc
commit 3634f8ee967c3adb60efc759f9aca885b83ba2bc
Author: Alexandre Oliva <oliva@gnu.org>
Date: Thu Dec 22 21:28:48 2022 -0300
hash set: reject attempts to insert null pointers
Diff:
---
gcc/hash-set.h | 6 +++++-
gcc/varpool.cc | 4 +++-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/gcc/hash-set.h b/gcc/hash-set.h
index 76fa7f39456..a98121a060e 100644
--- a/gcc/hash-set.h
+++ b/gcc/hash-set.h
@@ -58,7 +58,11 @@ public:
Key *e = m_table.find_slot_with_hash (k, Traits::hash (k), INSERT);
bool existed = !Traits::is_empty (*e);
if (!existed)
- new (e) Key (k);
+ {
+ new (e) Key (k);
+ // Catch attempts to insert e.g. a NULL pointer.
+ gcc_checking_assert (!Traits::is_empty (*e));
+ }
return existed;
}
diff --git a/gcc/varpool.cc b/gcc/varpool.cc
index bfd17f1250c..ccbd6e50f4b 100644
--- a/gcc/varpool.cc
+++ b/gcc/varpool.cc
@@ -680,10 +680,12 @@ symbol_table::remove_unreferenced_decls (void)
enqueue_node (vnode, &first);
else
{
- referenced.add (vnode);
+ if (vnode)
+ referenced.add (vnode);
while (vnode && vnode->alias && vnode->definition)
{
vnode = vnode->get_alias_target ();
+ gcc_checking_assert (vnode);
referenced.add (vnode);
}
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* [gcc(refs/users/aoliva/heads/testme)] hash set: reject attempts to insert null pointers
@ 2022-12-23 5:27 Alexandre Oliva
0 siblings, 0 replies; 3+ messages in thread
From: Alexandre Oliva @ 2022-12-23 5:27 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:a0ad3726dd1bed390cb8f0313d08c5e1d698c1ef
commit a0ad3726dd1bed390cb8f0313d08c5e1d698c1ef
Author: Alexandre Oliva <oliva@gnu.org>
Date: Thu Dec 22 21:28:48 2022 -0300
hash set: reject attempts to insert null pointers
Diff:
---
gcc/hash-set.h | 6 +++++-
gcc/varpool.cc | 4 +++-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/gcc/hash-set.h b/gcc/hash-set.h
index 76fa7f39456..a98121a060e 100644
--- a/gcc/hash-set.h
+++ b/gcc/hash-set.h
@@ -58,7 +58,11 @@ public:
Key *e = m_table.find_slot_with_hash (k, Traits::hash (k), INSERT);
bool existed = !Traits::is_empty (*e);
if (!existed)
- new (e) Key (k);
+ {
+ new (e) Key (k);
+ // Catch attempts to insert e.g. a NULL pointer.
+ gcc_checking_assert (!Traits::is_empty (*e));
+ }
return existed;
}
diff --git a/gcc/varpool.cc b/gcc/varpool.cc
index bfd17f1250c..ccbd6e50f4b 100644
--- a/gcc/varpool.cc
+++ b/gcc/varpool.cc
@@ -680,10 +680,12 @@ symbol_table::remove_unreferenced_decls (void)
enqueue_node (vnode, &first);
else
{
- referenced.add (vnode);
+ if (vnode)
+ referenced.add (vnode);
while (vnode && vnode->alias && vnode->definition)
{
vnode = vnode->get_alias_target ();
+ gcc_checking_assert (vnode);
referenced.add (vnode);
}
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* [gcc(refs/users/aoliva/heads/testme)] hash set: reject attempts to insert null pointers
@ 2022-12-23 0:58 Alexandre Oliva
0 siblings, 0 replies; 3+ messages in thread
From: Alexandre Oliva @ 2022-12-23 0:58 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:a655804c5d6e60a6a019a1c7f33d48549a823bf5
commit a655804c5d6e60a6a019a1c7f33d48549a823bf5
Author: Alexandre Oliva <oliva@gnu.org>
Date: Thu Dec 22 21:28:48 2022 -0300
hash set: reject attempts to insert null pointers
Diff:
---
gcc/hash-set.h | 6 +++++-
gcc/varpool.cc | 4 +++-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/gcc/hash-set.h b/gcc/hash-set.h
index 76fa7f39456..a98121a060e 100644
--- a/gcc/hash-set.h
+++ b/gcc/hash-set.h
@@ -58,7 +58,11 @@ public:
Key *e = m_table.find_slot_with_hash (k, Traits::hash (k), INSERT);
bool existed = !Traits::is_empty (*e);
if (!existed)
- new (e) Key (k);
+ {
+ new (e) Key (k);
+ // Catch attempts to insert e.g. a NULL pointer.
+ gcc_checking_assert (!Traits::is_empty (*e));
+ }
return existed;
}
diff --git a/gcc/varpool.cc b/gcc/varpool.cc
index bfd17f1250c..ccbd6e50f4b 100644
--- a/gcc/varpool.cc
+++ b/gcc/varpool.cc
@@ -680,10 +680,12 @@ symbol_table::remove_unreferenced_decls (void)
enqueue_node (vnode, &first);
else
{
- referenced.add (vnode);
+ if (vnode)
+ referenced.add (vnode);
while (vnode && vnode->alias && vnode->definition)
{
vnode = vnode->get_alias_target ();
+ gcc_checking_assert (vnode);
referenced.add (vnode);
}
}
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-12-23 7:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-23 7:31 [gcc(refs/users/aoliva/heads/testme)] hash set: reject attempts to insert null pointers Alexandre Oliva
-- strict thread matches above, loose matches on Subject: below --
2022-12-23 5:27 Alexandre Oliva
2022-12-23 0:58 Alexandre Oliva
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).