[Bug c++/108975] New: Internal compiler error on constexpr variable used as nontype template

2023-02-28 Thread samuelpmish at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108975

Bug ID: 108975
   Summary: Internal compiler error on constexpr variable used as
nontype template
   Product: gcc
   Version: 12.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: samuelpmish at gmail dot com
  Target Milestone: ---

Hi, 

I'm running into an internal compiler error with g++ (12.1.0):


internal compiler error: in lookup_template_class_1, at cp/pt.cc:10114
[build]   120 | using derivative_type   =
decltype(domain_integral::get_derivative_type(qf,
state_type{}));
[build]   |
   ^~~
[build] 0x662042 lookup_template_class_1
[build] ../../src/gcc/cp/pt.cc:10114
[build] 0x81c004 lookup_template_class(tree_node*, tree_node*, tree_node*,
tree_node*, int, int)
[build] ../../src/gcc/cp/pt.cc:10353
[build] 0x81c004 tsubst_aggr_type
[build] ../../src/gcc/cp/pt.cc:13747
[build] 0x80e549 tsubst_aggr_type
[build] ../../src/gcc/cp/pt.cc:17421
[build] 0x80e549 tsubst_copy
[build] ../../src/gcc/cp/pt.cc:16928
[build] 0x80fc58 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*,
bool, bool)
[build] ../../src/gcc/cp/pt.cc:21050
[build] 0x8200e8 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
[build] ../../src/gcc/cp/pt.cc:19491
[build] 0x81cfb2 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
[build] ../../src/gcc/cp/pt.cc:18462
[build] 0x81cfb2 tsubst_decl
[build] ../../src/gcc/cp/pt.cc:15004
[build] 0x80e92b tsubst_copy
[build] ../../src/gcc/cp/pt.cc:17000
[build] 0x80f4e1 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*,
bool, bool)
[build] ../../src/gcc/cp/pt.cc:21265
[build] 0x80fe8d tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*,
bool, bool)
[build] ../../src/gcc/cp/pt.cc:20117
[build] 0x8200e8 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
[build] ../../src/gcc/cp/pt.cc:19491
[build] 0x825bad tsubst_template_args(tree_node*, tree_node*, int, tree_node*)
[build] ../../src/gcc/cp/pt.cc:13517
[build] 0x8108fe tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*,
bool, bool)
[build] ../../src/gcc/cp/pt.cc:20055
[build] 0x80f865 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*,
bool, bool)
[build] ../../src/gcc/cp/pt.cc:20676
[build] 0x818c01 tsubst(tree_node*, tree_node*, int, tree_node*)
[build] ../../src/gcc/cp/pt.cc:16315
[build] 0x81c344 tsubst_decl
[build] ../../src/gcc/cp/pt.cc:14952
[build] 0x8226bb tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
[build] ../../src/gcc/cp/pt.cc:18590
[build] 0x821632 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
[build] ../../src/gcc/cp/pt.cc:18462

g++ (11.3.0) also fails in a similar way: 

internal compiler error: in lookup_template_class_1, at cp/pt.c:10093
[build]   120 | using derivative_type   =
decltype(domain_integral::get_derivative_type(qf,
state_type{}));
[build]   |
 ^~~
[build] 0x7fc84da29d8f __libc_start_call_main
[build] ../sysdeps/nptl/libc_start_call_main.h:58
[build] 0x7fc84da29e3f __libc_start_main_impl
[build] ../csu/libc-start.c:392

but g++ (10.4.0) and clang (14.0.0) compile the same code without any issues.

-

The line of code it referred to before the backtrace is something like:

  constexpr int dim = dimension_of(geom);
  [&](auto index) {
...
using derivative_type =
decltype(domain_integral::get_derivative_type(qf,
state_type{}));
...
  }

If I make `dim` static in addition to constexpr, then the internal compiler
error disappears. I've tried for a bit to come up with a smaller example that
reproduces this issue, but wasn't able to find one.

The full compilation line is (after removing some long include directory flags)

/usr/bin/g++-12 -DAXOM_DEBUG -DGTEST_HAS_DEATH_TEST=0 -Wall -Wextra  -pthread
-freport-bug -Werror  -Wshadow -Wdouble-promotion -Wconversion -Wundef
-Wnull-dereference -Wold-style-cast -g -fPIE -fopenmp -Wno-class-memaccess
-DCONDUIT_RELAY_IO_MPI_ENABLED -DCONDUIT_BLUEPRINT_MPI_ENABLED -std=c++17 -o
file.o -c file.cpp

Following the guidance in README.Bugs, I also compiled with -save-temps to
produce a .ii file, but it is too large to attach here, so I'll include a
dropbox link to it: https://www.dropbox.com/s/slrf8r500vargd5/file.ii?dl=0 

I'm new to submitting bugs to gcc/g++, so if there's any more information I can
provide please let me know.

Sam

[Bug c++/108975] Internal compiler error on constexpr variable used as nontype template

2023-02-28 Thread samuelpmish at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108975

--- Comment #2 from Sam Mish  ---
Does the dropbox link to the .ii file not work for you, Andrew?

[Bug c++/108975] [10/11/12/13 Regression] Internal compiler error on constexpr variable used as nontype template

2023-03-01 Thread samuelpmish at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108975

--- Comment #10 from Sam Mish  ---
Great-- thanks for finding such a small reproducer, Andrew.

[Bug ipa/102067] SEGFAULT in varpool_node::get_constructor during lto1 when optimising or not using debug symbols

2022-11-10 Thread samuelpmish at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102067

Sam Mish  changed:

   What|Removed |Added

 CC||samuelpmish at gmail dot com

--- Comment #22 from Sam Mish  ---
I'm hitting an issue similar to this in one of my projects:

gcc-12 (Ubuntu 12.1.0-2ubuntu1~22.04) 12.1.0


When linking with lto on a optimized build, gcc12 is crashing (apologies for
the long link line)

/usr/bin/g++-12 -Wall -Wextra  -pthread -save-temps -Werror  -Wshadow
-Wdouble-promotion -Wconversion -Wundef -Wnull-dereference -Wold-style-cast 
-O3 -DNDEBUG -rdynamic-fopenmp -Wl,-Bsymbolic-functions
src/serac/numerics/functional/tests/CMakeFiles/functional_qoi.dir/functional_qoi.cpp.o
-o tests/functional_qoi 
-Wl,-rpath,/home/sam/code/serac_libs_gcc12/gcc-12.1.0/lua-5.3.5-dquw3g42r65n5xisjxjm4qn77ztburb5/lib
 lib/libgtest_main.a  lib/libgtest.a  lib/libserac_state.a  lib/libserac_mesh.a
 lib/libserac_numerics.a  lib/libserac_infrastructure.a  lib/libaxom.a 
/home/sam/code/serac_libs_gcc12/gcc-12.1.0/umpire-2022.03.1-oh5f65jhr3zzxcaa52hbl5v6hokl7ukj/lib/libumpire.a

/home/sam/code/serac_libs_gcc12/gcc-12.1.0/raja-2022.03.0-ssk34466yhhqwld7szsrmbc65e4c5257/lib/libRAJA.a

/home/sam/code/serac_libs_gcc12/gcc-12.1.0/camp-2022.03.2-wb6wkruuotyvmioa4ngks4klpoiyxvp4/lib/libcamp.a

/home/sam/code/serac_libs_gcc12/gcc-12.1.0/hdf5-1.8.21-izgwwdm7ola6qvpco4g5th4ywabgnysx/lib/libhdf5.a

/home/sam/code/serac_libs_gcc12/gcc-12.1.0/conduit-0.8.4-upcl5uu5zbdtmgvtakiq3j3g7e52ilyu/lib/libconduit_relay_mpi_io.a

/home/sam/code/serac_libs_gcc12/gcc-12.1.0/conduit-0.8.4-upcl5uu5zbdtmgvtakiq3j3g7e52ilyu/lib/libconduit_relay.a
 -lrt 
/home/sam/code/serac_libs_gcc12/gcc-12.1.0/conduit-0.8.4-upcl5uu5zbdtmgvtakiq3j3g7e52ilyu/lib/libconduit_blueprint_mpi.a

/home/sam/code/serac_libs_gcc12/gcc-12.1.0/conduit-0.8.4-upcl5uu5zbdtmgvtakiq3j3g7e52ilyu/lib/libconduit_blueprint.a

/home/sam/code/serac_libs_gcc12/gcc-12.1.0/conduit-0.8.4-upcl5uu5zbdtmgvtakiq3j3g7e52ilyu/lib/libconduit_relay_mpi.a

/home/sam/code/serac_libs_gcc12/gcc-12.1.0/conduit-0.8.4-upcl5uu5zbdtmgvtakiq3j3g7e52ilyu/lib/libconduit.a

/home/sam/code/serac_libs_gcc12/gcc-12.1.0/lua-5.3.5-dquw3g42r65n5xisjxjm4qn77ztburb5/lib/liblua.so
 lib/libmfem.a  /usr/lib/gcc/x86_64-linux-gnu/12/libgomp.so 
/home/sam/code/serac_libs_gcc12/gcc-12.1.0/hypre-2.18.2-qjtod2f6fq6gs27xtac52qsogpaomxg5/lib/libHYPRE.a
 /usr/lib/x86_64-linux-gnu/libopenblas.so  -lm  -ldl 
/home/sam/code/serac_libs_gcc12/gcc-12.1.0/superlu-dist-6.1.1-dzfbn5o7xmj4afrbu5bobphtc6uo2cgl/lib/libsuperlu_dist.a

/home/sam/code/serac_libs_gcc12/gcc-12.1.0/parmetis-4.0.3-basm6qwardrie3ty4shbelvyadmtes3j/lib/libparmetis.a

/home/sam/code/serac_libs_gcc12/gcc-12.1.0/metis-5.1.0-srkgcb2bm5fwesct5zqa3y6h74jfwcf2/lib/libmetis.a

/home/sam/code/serac_libs_gcc12/gcc-12.1.0/sundials-5.7.0-jdioj6objpqshembk7pcv32vohhzw2qv/lib/libsundials_nvecserial.a

/home/sam/code/serac_libs_gcc12/gcc-12.1.0/sundials-5.7.0-jdioj6objpqshembk7pcv32vohhzw2qv/lib/libsundials_nvecparallel.a

/home/sam/code/serac_libs_gcc12/gcc-12.1.0/sundials-5.7.0-jdioj6objpqshembk7pcv32vohhzw2qv/lib/libsundials_nvecmpiplusx.a

/home/sam/code/serac_libs_gcc12/gcc-12.1.0/sundials-5.7.0-jdioj6objpqshembk7pcv32vohhzw2qv/lib/libsundials_cvodes.a

/home/sam/code/serac_libs_gcc12/gcc-12.1.0/sundials-5.7.0-jdioj6objpqshembk7pcv32vohhzw2qv/lib/libsundials_arkode.a

/home/sam/code/serac_libs_gcc12/gcc-12.1.0/sundials-5.7.0-jdioj6objpqshembk7pcv32vohhzw2qv/lib/libsundials_kinsol.a

/home/sam/code/serac_libs_gcc12/gcc-12.1.0/netcdf-c-4.7.4-ty2aqukbd6j7uuezhi7s42r7c7qqpynn/lib/libnetcdf.a

/home/sam/code/serac_libs_gcc12/gcc-12.1.0/hdf5-1.8.21-izgwwdm7ola6qvpco4g5th4ywabgnysx/lib/libhdf5_hl.a

/home/sam/code/serac_libs_gcc12/gcc-12.1.0/hdf5-1.8.21-izgwwdm7ola6qvpco4g5th4ywabgnysx/lib/libhdf5.a
 -lm  -ldl 
/home/sam/code/serac_libs_gcc12/gcc-12.1.0/hdf5-1.8.21-izgwwdm7ola6qvpco4g5th4ywabgnysx/lib/libhdf5.a
 /usr/lib/x86_64-linux-gnu/libz.so  /usr/lib/x86_64-linux-gnu/libmpichcxx.so 
/usr/lib/x86_64-linux-gnu/libmpich.so && :
[build] during IPA pass: icf
[build] lto1: internal compiler error: Segmentation fault
[build] 0xb1f113 crash_signal
[build] ../../src/gcc/toplev.cc:322
[build] 0x7fe21814551f ???
[build] ./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0
[build] 0xdda228 varpool_node::get_constructor()
[build] ../../src/gcc/varpool.cc:300
[build] 0x17aea53 ipa_icf::sem_variable::equals(ipa_icf::sem_item*,
hash_map, ipa_icf::sem_item*>
>&)
[build] ../../src/gcc/ipa-icf.cc:1697
[build] 0x17afabe
ipa_icf::sem_item_optimizer::subdivide_classes_by_equality(bool)
[build] ../../src/gcc/ipa-icf.cc:2732
[build] 0x17b7952 ipa_icf::sem_item_optimizer::execute()
[build] ../../src/gcc/ipa-icf.cc:2464
[build] 0x17b91ba ipa_icf_driver
[build] ../../src/gcc/ipa-icf.cc:3600
[build] 0x17b91ba ipa_icf::pass_ipa_icf::execute(function*)
[build] ../../src/gcc/i

[Bug ipa/102067] SEGFAULT in varpool_node::get_constructor during lto1 when optimising or not using debug symbols

2022-11-11 Thread samuelpmish at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102067

--- Comment #24 from Sam Mish  ---
> Good! Can you please provide steps how to build the reproducer project?

Unfortunately, this project uses a large and unconventional build system, so
it's difficult to reproduce. I could upload the `.ii` files, but each of the
libraries in that /home/sam/code/serac_libs_gcc12/gcc-12.1.0/ directory were
built custom (and might be relevant to the failure)

I can look into trying to reproduce the issue in a docker image-- would that be
helpful?