https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108693
Bug ID: 108693 Summary: Update shared character array inside OpenMP critical section causes internal compiler error Product: gcc Version: 12.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: hamchugh at amd dot com Target Milestone: --- Created attachment 54417 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54417&action=edit source code Good morning, I have a small FORTRAN source code where a shared character array is updated inside an OpenMP critical region. The source code is provided as openmp_test.F90. The code is compiled as: gfortran -v -O0 -Wall -Wextra -fno-strict-aliasing -fwrapv -fno-aggressive-loop-optimizations -fopenmp -save-temps openmp_test.F90 -o openmp-test-gfortran This causes an internal compiler error: Driving: gfortran -v -O0 -Wall -Wextra -fno-strict-aliasing -fwrapv -fno-aggressive-loop-optimizations -fopenmp -save-temps openmp_test.F90 -o openmp-test-gfortran -l gfortran -l m -shared-libgcc Reading specs from /home/harry/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.4.0/gcc-12.2.0-3m7sdjb7xtzzv6fawh5xgbd4c65zufw4/lib/gcc/x86_64-pc-linux-gnu/12.2.0/specs COLLECT_GCC=gfortran COLLECT_LTO_WRAPPER=/home/harry/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.4.0/gcc-12.2.0-3m7sdjb7xtzzv6fawh5xgbd4c65zufw4/libexec/gcc/x86_64-pc-linux-gnu/12.2.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /tmp/harry/spack-stage/spack-stage-gcc-12.2.0-3m7sdjb7xtzzv6fawh5xgbd4c65zufw4/spack-src/configure --prefix=/home/harry/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.4.0/gcc-12.2.0-3m7sdjb7xtzzv6fawh5xgbd4c65zufw4 --with-pkgversion='Spack GCC' --with-bugurl=https://github.com/spack/spack/issues --disable-multilib --enable-languages=c,c++,fortran --disable-nls --disable-canonical-system-headers --with-system-zlib --with-zstd-include=/home/harry/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.4.0/zstd-1.5.2-m4lztdopwi2qzqvt3jtfaznftfdwv47n/include --with-zstd-lib=/home/harry/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.4.0/zstd-1.5.2-m4lztdopwi2qzqvt3jtfaznftfdwv47n/lib --enable-bootstrap --with-mpfr-include=/home/harry/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.4.0/mpfr-4.1.0-3cmjotnpqe4o4jrfqj4trvnpefv5us6y/include --with-mpfr-lib=/home/harry/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.4.0/mpfr-4.1.0-3cmjotnpqe4o4jrfqj4trvnpefv5us6y/lib --with-gmp-include=/home/harry/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.4.0/gmp-6.2.1-wo7ihyuv7rdybfgoxj3lgspjpqfipkn7/include --with-gmp-lib=/home/harry/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.4.0/gmp-6.2.1-wo7ihyuv7rdybfgoxj3lgspjpqfipkn7/lib --with-mpc-include=/home/harry/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.4.0/mpc-1.2.1-66jzajqy27dj57ltanedqoqq5l7glu2v/include --with-mpc-lib=/home/harry/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.4.0/mpc-1.2.1-66jzajqy27dj57ltanedqoqq5l7glu2v/lib --without-isl --with-stage1-ldflags='-Wl,-rpath,/home/harry/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.4.0/gcc-12.2.0-3m7sdjb7xtzzv6fawh5xgbd4c65zufw4/lib -Wl,-rpath,/home/harry/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.4.0/gcc-12.2.0-3m7sdjb7xtzzv6fawh5xgbd4c65zufw4/lib64 -Wl,-rpath,/home/harry/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.4.0/gmp-6.2.1-wo7ihyuv7rdybfgoxj3lgspjpqfipkn7/lib -Wl,-rpath,/home/harry/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.4.0/mpc-1.2.1-66jzajqy27dj57ltanedqoqq5l7glu2v/lib -Wl,-rpath,/home/harry/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.4.0/mpfr-4.1.0-3cmjotnpqe4o4jrfqj4trvnpefv5us6y/lib -Wl,-rpath,/home/harry/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.4.0/zlib-1.2.13-4sy72bkxib5hfr2zuhmn2wmieakmxolq/lib -Wl,-rpath,/home/harry/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.4.0/zstd-1.5.2-m4lztdopwi2qzqvt3jtfaznftfdwv47n/lib' --with-boot-ldflags='-Wl,-rpath,/home/harry/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.4.0/gcc-12.2.0-3m7sdjb7xtzzv6fawh5xgbd4c65zufw4/lib -Wl,-rpath,/home/harry/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.4.0/gcc-12.2.0-3m7sdjb7xtzzv6fawh5xgbd4c65zufw4/lib64 -Wl,-rpath,/home/harry/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.4.0/gmp-6.2.1-wo7ihyuv7rdybfgoxj3lgspjpqfipkn7/lib -Wl,-rpath,/home/harry/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.4.0/mpc-1.2.1-66jzajqy27dj57ltanedqoqq5l7glu2v/lib -Wl,-rpath,/home/harry/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.4.0/mpfr-4.1.0-3cmjotnpqe4o4jrfqj4trvnpefv5us6y/lib -Wl,-rpath,/home/harry/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.4.0/zlib-1.2.13-4sy72bkxib5hfr2zuhmn2wmieakmxolq/lib -Wl,-rpath,/home/harry/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.4.0/zstd-1.5.2-m4lztdopwi2qzqvt3jtfaznftfdwv47n/lib -static-libstdc++ -static-libgcc' --with-build-config=spack Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 12.2.0 (Spack GCC) COLLECT_GCC_OPTIONS='-v' '-O0' '-Wall' '-Wextra' '-fno-strict-aliasing' '-fwrapv' '-fno-aggressive-loop-optimizations' '-fopenmp' '-save-temps' '-o' 'openmp-test-gfortran' '-shared-libgcc' '-mtune=generic' '-march=x86-64' '-pthread' '-dumpdir' 'openmp-test-gfortran-' /home/harry/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.4.0/gcc-12.2.0-3m7sdjb7xtzzv6fawh5xgbd4c65zufw4/libexec/gcc/x86_64-pc-linux-gnu/12.2.0/f951 openmp_test.F90 -cpp=openmp-test-gfortran-openmp_test.f90 -quiet -v -imultiarch x86_64-linux-gnu -D_REENTRANT openmp_test.F90 -quiet -dumpdir openmp-test-gfortran- -dumpbase openmp_test.F90 -dumpbase-ext .F90 -mtune=generic -march=x86-64 -O0 -Wall -Wextra -version -fno-strict-aliasing -fwrapv -fno-aggressive-loop-optimizations -fopenmp -fintrinsic-modules-path /home/harry/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.4.0/gcc-12.2.0-3m7sdjb7xtzzv6fawh5xgbd4c65zufw4/lib/gcc/x86_64-pc-linux-gnu/12.2.0/finclude -fpre-include=/usr/include/finclude/math-vector-fortran.h -o openmp-test-gfortran-openmp_test.s GNU Fortran (Spack GCC) version 12.2.0 (x86_64-pc-linux-gnu) compiled by GNU C version 12.2.0, GMP version 6.2.1, MPFR version 4.1.0, MPC version 1.2.1, isl version none GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu" ignoring nonexistent directory "/home/harry/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.4.0/gcc-12.2.0-3m7sdjb7xtzzv6fawh5xgbd4c65zufw4/lib/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../x86_64-pc-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /home/harry/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.4.0/gcc-12.2.0-3m7sdjb7xtzzv6fawh5xgbd4c65zufw4/lib/gcc/x86_64-pc-linux-gnu/12.2.0/finclude . /home/harry/amd/aocc-compiler-4.0.0/include /home/harry/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.4.0/gcc-12.2.0-3m7sdjb7xtzzv6fawh5xgbd4c65zufw4/lib/gcc/x86_64-pc-linux-gnu/12.2.0/include /usr/local/include /home/harry/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.4.0/gcc-12.2.0-3m7sdjb7xtzzv6fawh5xgbd4c65zufw4/include /home/harry/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.4.0/gcc-12.2.0-3m7sdjb7xtzzv6fawh5xgbd4c65zufw4/lib/gcc/x86_64-pc-linux-gnu/12.2.0/include-fixed /usr/include/x86_64-linux-gnu /usr/include End of search list. GNU Fortran2008 (Spack GCC) version 12.2.0 (x86_64-pc-linux-gnu) compiled by GNU C version 12.2.0, GMP version 6.2.1, MPFR version 4.1.0, MPC version 1.2.1, isl version none GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 during GIMPLE pass: omplower openmp_test.F90:38:64: 38 | !$OMP PARALLEL DEFAULT(NONE) SHARED(mask) PRIVATE(thread_id) | ^ internal compiler error: in gimplify_expr, at gimplify.cc:15428 0x67e01e gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) /tmp/harry/spack-stage/spack-stage-gcc-12.2.0-3m7sdjb7xtzzv6fawh5xgbd4c65zufw4/spack-src/gcc/gimplify.cc:15428 0xa3a2be gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) /tmp/harry/spack-stage/spack-stage-gcc-12.2.0-3m7sdjb7xtzzv6fawh5xgbd4c65zufw4/spack-src/gcc/gimplify.cc:15866 0xa3ef7f internal_get_tmp_var /tmp/harry/spack-stage/spack-stage-gcc-12.2.0-3m7sdjb7xtzzv6fawh5xgbd4c65zufw4/spack-src/gcc/gimplify.cc:626 0xa3c0f5 get_initialized_tmp_var(tree_node*, gimple**, gimple**, bool) /tmp/harry/spack-stage/spack-stage-gcc-12.2.0-3m7sdjb7xtzzv6fawh5xgbd4c65zufw4/spack-src/gcc/gimplify.cc:681 0xa3c0f5 gimplify_save_expr /tmp/harry/spack-stage/spack-stage-gcc-12.2.0-3m7sdjb7xtzzv6fawh5xgbd4c65zufw4/spack-src/gcc/gimplify.cc:6395 0xa3c0f5 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) /tmp/harry/spack-stage/spack-stage-gcc-12.2.0-3m7sdjb7xtzzv6fawh5xgbd4c65zufw4/spack-src/gcc/gimplify.cc:15399 0xa3a23f gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) /tmp/harry/spack-stage/spack-stage-gcc-12.2.0-3m7sdjb7xtzzv6fawh5xgbd4c65zufw4/spack-src/gcc/gimplify.cc:15875 0xa3fde9 gimplify_expr /tmp/harry/spack-stage/spack-stage-gcc-12.2.0-3m7sdjb7xtzzv6fawh5xgbd4c65zufw4/spack-src/gcc/gimplify.cc:16157 0xa3fde9 gimplify_arg(tree_node**, gimple**, unsigned int, bool) /tmp/harry/spack-stage/spack-stage-gcc-12.2.0-3m7sdjb7xtzzv6fawh5xgbd4c65zufw4/spack-src/gcc/gimplify.cc:3502 0xa40034 gimplify_call_expr /tmp/harry/spack-stage/spack-stage-gcc-12.2.0-3m7sdjb7xtzzv6fawh5xgbd4c65zufw4/spack-src/gcc/gimplify.cc:3739 0xa3abb8 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) /tmp/harry/spack-stage/spack-stage-gcc-12.2.0-3m7sdjb7xtzzv6fawh5xgbd4c65zufw4/spack-src/gcc/gimplify.cc:15070 0xa4586d gimplify_modify_expr /tmp/harry/spack-stage/spack-stage-gcc-12.2.0-3m7sdjb7xtzzv6fawh5xgbd4c65zufw4/spack-src/gcc/gimplify.cc:6085 0xa39f23 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) /tmp/harry/spack-stage/spack-stage-gcc-12.2.0-3m7sdjb7xtzzv6fawh5xgbd4c65zufw4/spack-src/gcc/gimplify.cc:15098 0xa3b515 gimplify_stmt(tree_node**, gimple**) /tmp/harry/spack-stage/spack-stage-gcc-12.2.0-3m7sdjb7xtzzv6fawh5xgbd4c65zufw4/spack-src/gcc/gimplify.cc:7151 0xa3b515 gimplify_statement_list /tmp/harry/spack-stage/spack-stage-gcc-12.2.0-3m7sdjb7xtzzv6fawh5xgbd4c65zufw4/spack-src/gcc/gimplify.cc:2019 0xa3b515 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) /tmp/harry/spack-stage/spack-stage-gcc-12.2.0-3m7sdjb7xtzzv6fawh5xgbd4c65zufw4/spack-src/gcc/gimplify.cc:15543 0xa42fd2 gimplify_stmt(tree_node**, gimple**) /tmp/harry/spack-stage/spack-stage-gcc-12.2.0-3m7sdjb7xtzzv6fawh5xgbd4c65zufw4/spack-src/gcc/gimplify.cc:7151 0xa42fd2 gimplify_cond_expr /tmp/harry/spack-stage/spack-stage-gcc-12.2.0-3m7sdjb7xtzzv6fawh5xgbd4c65zufw4/spack-src/gcc/gimplify.cc:4493 0xa3abd7 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) /tmp/harry/spack-stage/spack-stage-gcc-12.2.0-3m7sdjb7xtzzv6fawh5xgbd4c65zufw4/spack-src/gcc/gimplify.cc:15055 0xa416fd gimplify_stmt(tree_node**, gimple**) /tmp/harry/spack-stage/spack-stage-gcc-12.2.0-3m7sdjb7xtzzv6fawh5xgbd4c65zufw4/spack-src/gcc/gimplify.cc:7151 Please submit a full bug report, with preprocessed source (by using -freport-bug). Please include the complete backtrace with any bug report. See <https://github.com/spack/spack/issues> for instructions. The exact compiler version is: GNU Fortran (Spack GCC) 12.2.0 Copyright (C) 2022 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Using the Godbolt compiler explorer website I can narrow this error being introduced sometime between Gfortran v5.5 (successfully compiles) and v6.3 (does not compile). Best regards, Harry