https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108286
Bug ID: 108286 Summary: [GCC 12/13] OpenMP Target directive causes internal compiler error Product: gcc Version: 12.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libgomp Assignee: unassigned at gcc dot gnu.org Reporter: j.reu...@fz-juelich.de CC: jakub at gcc dot gnu.org Target Milestone: --- Created attachment 54189 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54189&action=edit Source Code, .ii and .s file of GCC 12, .out file of GCC 13 (experimental) I've been tinkering around with OpenMP Target in the last few weeks. I ran into issues with other compilers while testing omp target enter and exit data. While trying GCC, I ran into a Segmentation Fault during the compilation. I could reduce the source code to the code shown below. Tested system: - Fedora Linux 37 - GCC 12.2.1 I was able to reproduce the same error with GodBolt using both x86-64 gcc 12.2 and x86-64 gcc 12.1 and the GCC 12.2 Docker container. Previous versions (11.x and lower) throw error messages during compilation instead and do not crash. Link: https://godbolt.org/z/E5f6G7dP9 GCC 13.0 (2023-01-01) also results in internal compiler errors with the error message (Preprocessed source of that version attached as well): internal compiler error: tree check: expected private or shared or firstprivate or lastprivate or reduction or task_reduction or in_reduction or copyin or copyprivate or linear or affinity or aligned or allocate or depend or nontemporal or uniform or enter or link or detach or use_device_ptr or use_device_addr or is_device_ptr or inclusive or exclusive or from or to or map or has_device_addr or doacross or _cache_ or gang or async or wait or auto or seq or _looptemp_ or _reductemp_ or _condtemp_ or _scantemp_, have abs_expr in finish_omp_target_clauses, at cp/semantics.cc:9830 How to reproduce: --> error.cpp class ErrorClass { void causeError() { #pragma omp target map(size, ptr[:size]) nowait #pragma omp teams float error = ptr[0]; } unsigned size = 5; float* ptr = new float[size]; }; bash> g++ -fopenmp error.cpp error.cpp: In member function 'void ErrorClass::causeError()': error.cpp:5:25: internal compiler error: Segmentation fault 5 | float error = ptr[0]; | ^ 0x1bb069e internal_error(char const*, ...) ???:0 0x8b4857 finish_omp_target_clauses(unsigned int, tree_node*, tree_node**) ???:0 0x8b6824 finish_omp_target(unsigned int, tree_node*, tree_node*, bool) ???:0 0x861eaa c_parse_file() ???:0 0x93e4e5 c_common_parse_file() ???:0 Please submit a full bug report, with preprocessed source (by using -freport-bug). Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions. Compiler returned: 1