Bug 52742 - Initializing an array using brace initializer and template parameters
Summary: Initializing an array using brace initializer and template parameters
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: 4.8.1
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-03-27 18:52 UTC by Mat
Modified: 2015-08-12 17:19 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 4.8.1
Known to fail: 4.7.4, 4.8.0
Last reconfirmed: 2012-03-29 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mat 2012-03-27 18:52:48 UTC
This follows on from this question on stackoverflow.com:

http://stackoverflow.com/questions/9894406/initializing-a-const-instance-member-array

This has been tested on three versions of GCC (4.7, 4.6.3 and 4.5) on a variety of systems.

Output from 4.5 and 4.6.3 are both: http://ideone.com/h7K7y

Output from 4.7 is slightly different: http://pastie.org/3679616

Latter includes preprocessed output, using The following:

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.6/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.6.3-1' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++,go --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-plugin --enable-objc-gc --with-arch-32=i586 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.6.3 (Debian 4.6.3-1)
Comment 1 Mat 2012-03-28 07:07:58 UTC
A shorter reproducer has been shown here: https://gist.github.com/2220810

This does not actually have the template parameters inside the braces.
Comment 2 Paolo Carlini 2012-03-29 16:43:47 UTC
To wit:

void foo() {
  new int[1] {1};
}

template<int A>
void goo() {
  new int[1] {1};
}

int main() {
  foo();
  goo<1>();
}
Comment 3 Jonathan Wakely 2015-05-20 13:09:59 UTC
This is fixed in 4.8.1
Comment 4 paolo@gcc.gnu.org 2015-08-12 17:18:45 UTC
Author: paolo
Date: Wed Aug 12 17:18:14 2015
New Revision: 226824

URL: https://gcc.gnu.org/viewcvs?rev=226824&root=gcc&view=rev
Log:
2015-08-12  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/52742
	* g++.dg/cpp0x/pr52742.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/pr52742.C
Modified:
    trunk/gcc/testsuite/ChangeLog
Comment 5 Paolo Carlini 2015-08-12 17:19:30 UTC
Closing.