diff mbox series

Add default bitmap obstack allocation check

Message ID 20240503112616.D8A5E139CB@imap1.dmz-prg2.suse.org
State New
Headers show
Series Add default bitmap obstack allocation check | expand

Commit Message

Richard Biener May 3, 2024, 11:26 a.m. UTC
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 mbox series

Patch

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;