[Bug c++/88741] New: [9 Regression] Spurious "too long" error inside template

steinar+gcc at gunderson dot no gcc-bugzilla@gcc.gnu.org
Mon Jan 7 15:01:00 GMT 2019


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

            Bug ID: 88741
           Summary: [9 Regression] Spurious "too long" error inside
                    template
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: steinar+gcc at gunderson dot no
  Target Milestone: ---

Hi,

Since recent GCC 9 snapshots, this code now fails:

template <class T>
void foo() {
        char row[] = {"test"};
}

void bar() {
        foo<int>();
}       

I believe it's spurious, since the code works fine outside a template. Works
with GCC 8 and Clang 7.

atum17:~> /usr/lib/gcc-snapshot/bin/g++ -v                       
Using built-in specs.
COLLECT_GCC=/usr/lib/gcc-snapshot/bin/g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc-snapshot/libexec/gcc/x86_64-linux-gnu/9/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 20190102-1'
--with-bugurl=file:///usr/share/doc/gcc-snapshot/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++
--prefix=/usr/lib/gcc-snapshot --with-gcc-major-version-only --program-prefix=
--enable-shared --enable-linker-build-id --disable-nls --with-sysroot=/
--enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-plugin --with-system-zlib
--with-target-system-zlib --enable-objc-gc=auto --enable-multiarch
--disable-werror --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none --enable-checking=yes
--build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 9.0.0 20190102 (experimental) [trunk revision 267505] (Debian
20190102-1) 
atum17:~> /usr/lib/gcc-snapshot/bin/g++ -c test.cc        
test.cc: In instantiation of 'void foo() [with T = int]':
test.cc:3:23:   required from here
test.cc:1:47: error: initializer-string for array of chars is too long
[-fpermissive]
    1 | template <class T> void foo() { char row[] = {"test"}; }
      |


More information about the Gcc-bugs mailing list