[Bug c/102797] ice in useless_type_conversion_p, at gimple-expr.c:87

2021-10-16 Thread dimhen at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102797

--- Comment #2 from Dmitry G. Dyachenko  ---
r12-4256 PASS
r12- FAIL

$ cat x.ii
struct b {
  b(int);
};
void d() {
  int c = 1;
  do
try {
  b a = 1;
  while (1) {
c++;
a = 1;
  }
} catch (...) {
}
  while (1);
}

$ g++ -fpreprocessed -O2 -std=c++98 -c x.ii
during GIMPLE pass: evrp
x.ii: In function 'void d()':
x.ii:16:1: internal compiler error: tree check: expected class 'type', have
'exceptional' (error_mark) in useless_type_conversion_p, at gimple-expr.c:87
   16 | }
  | ^
0x90e691 tree_class_check_failed(tree_node const*, tree_code_class, char
const*, int, char const*)
/home/dimhen/src/gcc_current/gcc/tree.c:8739
0x7fcfb1 tree_class_check(tree_node*, tree_code_class, char const*, int, char
const*)
/home/dimhen/src/gcc_current/gcc/tree.h:3556
0x7fcfb1 useless_type_conversion_p(tree_node*, tree_node*)
/home/dimhen/src/gcc_current/gcc/gimple-expr.c:87
0x169677a verify_gimple_phi
/home/dimhen/src/gcc_current/gcc/tree-cfg.c:5128
0x169677a verify_gimple_in_cfg(function*, bool)
/home/dimhen/src/gcc_current/gcc/tree-cfg.c:5457
0x154ad27 execute_function_todo
/home/dimhen/src/gcc_current/gcc/passes.c:2042
0x154b73c execute_todo
/home/dimhen/src/gcc_current/gcc/passes.c:2096
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.

$ g++ -v
Using built-in specs.
COLLECT_GCC=/home/dimhen/arch-gcc/gcc_current/bin/g++
COLLECT_LTO_WRAPPER=/home/dimhen/arch-gcc/gcc_current/libexec/gcc/x86_64-pc-linux-gnu/12.0.0/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
Target: x86_64-pc-linux-gnu
Configured with: /home/dimhen/src/gcc_current/configure
--prefix=/home/dimhen/arch-gcc/gcc_current
--enable-checking=yes,df,fold,rtl,extra --enable-languages=c,c++,lto
--disable-multilib --enable-shared --enable-threads=posix --enable-__cxa_atexit
--enable-gnu-unique-object --enable-linker-build-id
--with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl
--enable-offload-targets=nvptx-none --without-cuda-driver
--enable-gnu-indirect-function --enable-cet --with-tune=native
--enable-libstdcxx-debug
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.0.0 20211015 (experimental) [master r12--ga01704fc45a] (GCC)

[Bug c/102797] ice in useless_type_conversion_p, at gimple-expr.c:87

2021-10-16 Thread dcb314 at hotmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102797

--- Comment #1 from David Binderman  ---
Reduced C code is

glib_autoptr_cleanup_GdkPaintable(struct _GdkPaintable **_ptr) {
  glib_autoptr_clear_GdkPaintable(*_ptr);
}
glib_autoptr_clear_GdkRGBA(struct _GdkRGBA *_ptr) {
  if (_ptr)
gdk_rgba_free();
}
glib_autoptr_cleanup_GdkRGBA(struct _GdkRGBA **_ptr) {
  glib_autoptr_clear_GdkRGBA(*_ptr);
}
gtd_sidebar_list_row_set_property() {
  __attribute__((cleanup(glib_autoptr_cleanup_GdkPaintable))) *paintable = 0;
  __attribute__((cleanup(glib_autoptr_cleanup_GdkRGBA))) *color = 0;
  color = gtd_task_list_get_color();
  paintable = gtd_create_circular_paintable();
  gtk_image_set_from_paintable();
}

Flag -march=bdver2 not required for the reduced code, only  -O2 -fexceptions.