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

            Bug ID: 80269
           Summary: ICE with compile time constant sized array when using
                    address sanitizer
           Product: gcc
           Version: 6.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: sanitizer
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nils at os dot inf.tu-dresden.de
                CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org,
                    jakub at gcc dot gnu.org, kcc at gcc dot gnu.org
  Target Milestone: ---

Created attachment 41093
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41093&action=edit
Preprocessed test file

I experience an internal compiler error when assigning to an array with
constant size, given by an expression, and building with C++11 and address
sanitizers. Here is a minimal example:

#include <stdio.h>
#include <algorithm>

const int LIM = std::max(10, 12);

int main() {
        char array[LIM] = "";
        printf("%s\n", array);
        return 0;
}

And compiling with:

g++ -std=c++11 -fsanitize=address test.cc

The result is:

test.cc:10:1: internal compiler error: in tree_to_uhwi, at tree.h:4044
 }
 ^
0xae594f tree_to_uhwi(tree_node const*)
        ../../gcc/gcc/tree.h:4044
0xae594f asan_add_global
        ../../gcc/gcc/asan.c:2269
0xae59b2 add_string_csts(constant_descriptor_tree**,
asan_add_string_csts_data*)
        ../../gcc/gcc/asan.c:2483
0xae5e2a void hash_table<tree_descriptor_hasher,
xcallocator>::traverse_noresize<asan_add_string_csts_data*,
&(add_string_csts(constant_descriptor_tree**,
asan_add_string_csts_data*))>(asan_add_string_csts_data*)
        ../../gcc/gcc/hash-table.h:950
0xae5e2a void hash_table<tree_descriptor_hasher,
xcallocator>::traverse<asan_add_string_csts_data*,
&(add_string_csts(constant_descriptor_tree**,
asan_add_string_csts_data*))>(asan_add_string_csts_data*)
        ../../gcc/gcc/hash-table.h:972
0xae5e2a asan_finish_file()
        ../../gcc/gcc/asan.c:2555


My system is:
$ uname -a
Linux erwin 4.9.5 #1 SMP Mon Jan 23 14:42:51 CET 2017 x86_64 GNU/Linux

$ g++ -v
Using built-in specs.
COLLECT_GCC=/usr/local/gcc/host-x86_64/6/bin/g++
COLLECT_LTO_WRAPPER=/usr/local/gcc/host-x86_64/6/libexec/gcc/x86_64-pc-linux-gnu/6.3.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc/configure --prefix=/usr/local/gcc/host-x86_64/6
--enable-shared --enable-__cxa_atexit
--enable-languages=c,c++,fortran,go,java,lto,objc --enable-libmpx
--enable-plugin --enable-default-pie --with-system-zlib
--disable-browser-plugin --enable-objc-gc=auto --enable-multiarch
--with-arch-32=i686 --with-abi=m64 --enable-multilib --with-tune=generic :
(reconfigured) ../gcc/configure --prefix=/usr/local/gcc/host-x86_64/6
--enable-shared --enable-__cxa_atexit
--enable-languages=c,c++,fortran,go,java,lto,objc --enable-libmpx
--enable-plugin --enable-default-pie --with-system-zlib
--disable-browser-plugin --enable-objc-gc=auto --enable-multiarch
--with-arch-32=i686 --with-abi=m64 --enable-multilib --with-tune=generic
Thread model: posix
gcc version 6.3.1 20170326 (GCC)

I've attached the preprocessor output, just in case.

Reply via email to