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

            Bug ID: 71514
           Summary: ICE on C11 code with atomic exchange at -O1 and above
                    on x86_64-linux-gnu: in copy_reference_ops_from_ref,
                    at tree-ssa-sccvn.c:879
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: su at cs dot ucdavis.edu
  Target Milestone: ---

The following C11 code causes an ICE when compiled with the current GCC trunk
on x86_64-linux-gnu in both 32-bit and 64-bit modes.  

It also affects at least 4.8.x and later. 


$ gcc-trunk -v
Using built-in specs.
COLLECT_GCC=gcc-trunk
COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/7.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-source-trunk/configure --enable-languages=c,c++,lto
--prefix=/usr/local/gcc-trunk --disable-bootstrap
Thread model: posix
gcc version 7.0.0 20160612 (experimental) [trunk revision 237336] (GCC) 
$ 
$ gcc-trunk -O0 -std=c11 small.c
$ 
$ gcc-trunk -O1 -std=c11 small.c
small.c: In function ‘main’:
small.c:9:1: internal compiler error: in copy_reference_ops_from_ref, at
tree-ssa-sccvn.c:879
 }
 ^
0xd89d6b copy_reference_ops_from_ref
        ../../gcc-source-trunk/gcc/tree-ssa-sccvn.c:879
0xd8af25 valueize_shared_reference_ops_from_ref
        ../../gcc-source-trunk/gcc/tree-ssa-sccvn.c:1500
0xd8c5d5 vn_reference_lookup(tree_node*, tree_node*, vn_lookup_kind,
vn_reference_s**, bool)
        ../../gcc-source-trunk/gcc/tree-ssa-sccvn.c:2369
0xd8f4c1 visit_reference_op_load
        ../../gcc-source-trunk/gcc/tree-ssa-sccvn.c:3463
0xd8f4c1 visit_use
        ../../gcc-source-trunk/gcc/tree-ssa-sccvn.c:3795
0xd913c5 process_scc
        ../../gcc-source-trunk/gcc/tree-ssa-sccvn.c:4015
0xd913c5 extract_and_process_scc_for_name
        ../../gcc-source-trunk/gcc/tree-ssa-sccvn.c:4102
0xd913c5 DFS
        ../../gcc-source-trunk/gcc/tree-ssa-sccvn.c:4154
0xd91b47 sccvn_dom_walker::before_dom_children(basic_block_def*)
        ../../gcc-source-trunk/gcc/tree-ssa-sccvn.c:4636
0x126a756 dom_walker::walk(basic_block_def*)
        ../../gcc-source-trunk/gcc/domwalk.c:265
0xd92f22 run_scc_vn(vn_lookup_kind)
        ../../gcc-source-trunk/gcc/tree-ssa-sccvn.c:4747
0xd62752 execute
        ../../gcc-source-trunk/gcc/tree-ssa-pre.c:4882
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.

$ 


------------------------------------------------------


void foo () {}

char a, b; 

int main ()
{
  __atomic_exchange (&a, &foo, &b, __ATOMIC_RELAXED);
  return 0; 
}

Reply via email to