public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Add default bitmap obstack allocation check
@ 2024-05-03 11:26 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2024-05-03 11:26 UTC (permalink / raw)
  To: gcc-patches

The following adds a check that the global bitmap obstack is initialized
when allocating a bitmap from it.

Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.

	* bitmap.cc (bitmap_alloc): When using the global bitmap obstack
	assert that is initialized.
---
 gcc/bitmap.cc | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/gcc/bitmap.cc b/gcc/bitmap.cc
index 459e32c1ad1..0905cde696f 100644
--- a/gcc/bitmap.cc
+++ b/gcc/bitmap.cc
@@ -781,7 +781,10 @@ bitmap_alloc (bitmap_obstack *bit_obstack MEM_STAT_DECL)
   bitmap map;
 
   if (!bit_obstack)
-    bit_obstack = &bitmap_default_obstack;
+    {
+      gcc_assert (bitmap_default_obstack_depth > 0);
+      bit_obstack = &bitmap_default_obstack;
+    }
   map = bit_obstack->heads;
   if (map)
     bit_obstack->heads = (class bitmap_head *) map->first;
-- 
2.35.3

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-05-03 11:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-03 11:26 [PATCH] Add default bitmap obstack allocation check Richard Biener

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).