[Bug c++/93443] New: gcc/cp/coroutines.cc:3555:23: runtime error: load of value 255, which is not a valid value for type 'bool'

marxin at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sun Jan 26 13:46:00 GMT 2020


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93443

            Bug ID: 93443
           Summary: gcc/cp/coroutines.cc:3555:23: runtime error: load of
                    value 255, which is not a valid value for type 'bool'
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: marxin at gcc dot gnu.org
                CC: iains at gcc dot gnu.org
            Blocks: 63426
  Target Milestone: ---

I see the following UBSAN which one can easily reproduce with:

diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc
index 81fb8c924a7..0c4014c27da 100644
--- a/gcc/cp/coroutines.cc
+++ b/gcc/cp/coroutines.cc
@@ -3533,10 +3533,12 @@ morph_fn_to_coro (tree orig, tree *resumer, tree
*destroyer)
      logically doing things related to the end of the function.  */
   /* done, we just need the return value.  */
   bool no_warning;
+  bool no_warning_initialized = false;
   if (same_type_p (TREE_TYPE (gro), fn_return_type))
     {
       /* Already got the result.  */
       r = check_return_expr (DECL_RESULT (orig), &no_warning);
+      no_warning_initialized = true;
     }
   else
     {
@@ -3552,6 +3554,7 @@ morph_fn_to_coro (tree orig, tree *resumer, tree
*destroyer)
     }

   r = build_stmt (input_location, RETURN_EXPR, DECL_RESULT (orig));
+  gcc_assert (no_warning_initialized);
   TREE_NO_WARNING (r) |= no_warning;
   r = maybe_cleanup_point_expr_void (r);
   add_stmt (r);

$ g++ co-yield-03-tmpl.C -fcoroutines -c
co-yield-03-tmpl.C: In instantiation of ‘looper<T> f() [with T = int]’:
co-yield-03-tmpl.C:105:25:   required from here
co-yield-03-tmpl.C:99:1: internal compiler error: in morph_fn_to_coro, at
cp/coroutines.cc:3557
   99 | }
      | ^
0xb1389f morph_fn_to_coro(tree_node*, tree_node**, tree_node**)
        ../../gcc/cp/coroutines.cc:3557
0xc43e5e finish_function(bool)
        ../../gcc/cp/decl.c:16853
0x103d3a1 instantiate_decl(tree_node*, bool, bool)
        ../../gcc/cp/pt.c:25524
0x103e1e6 instantiate_pending_templates(int)
        ../../gcc/cp/pt.c:25620
0xc90f2a c_parse_final_cleanups()
        ../../gcc/cp/decl2.c:4871
0x13223d9 c_common_parse_file()
        ../../gcc/c-family/c-opts.c:1208
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63426
[Bug 63426] [meta-bug] Issues found with -fsanitize=undefined


More information about the Gcc-bugs mailing list