Bug 56646 - [4.7/4.8/4.9 Regression] ICE: in cp_parser_late_return_type_opt, at cp/parser.c:16970
Summary: [4.7/4.8/4.9 Regression] ICE: in cp_parser_late_return_type_opt, at cp/parser...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.7.2
: P3 normal
Target Milestone: 4.7.3
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-03-18 00:40 UTC by pramod gupta
Modified: 2013-03-23 11:04 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.6.4, 4.7.3, 4.8.1, 4.9.0
Known to fail: 4.7.2, 4.8.0
Last reconfirmed: 2013-03-18 00:00:00


Attachments
Preprocessed source (300 bytes, application/octet-stream)
2013-03-18 00:40 UTC, pramod gupta
Details

Note You need to log in before you can comment on or make changes to this bug.
Description pramod gupta 2013-03-18 00:40:56 UTC
Created attachment 29686 [details]
Preprocessed source

Return type resolution fails for functions inside a struct declared inside other class Methods.

Tested on both g++4.7 (Debian 4.7.2-4) and g++ Snapshot (4.8.0 20130316)

$ /usr/lib/gcc-snapshot/bin/g++ -v -save-temps -Wall -Wextra -std=gnu++0x abc.cc 
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/4.8.0/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 20130316-1' --with-bugurl=file:///usr/share/doc/gcc-snapshot/README.Bugs --enable-languages=c,ada,c++,java,go,fortran,objc,obj-c++ --prefix=/usr/lib/gcc-snapshot --enable-shared --enable-linker-build-id --disable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-snap-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-snap-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-snap-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --with-arch-32=i586 --with-abi=m64 --with-multilib-list=m32,m64 --with-tune=generic --disable-werror --enable-checking=yes --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.8.0 20130316 (experimental) [trunk revision 196694] (Debian 20130316-1) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-Wall' '-Wextra' '-std=gnu++11' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
 /usr/lib/gcc-snapshot/libexec/gcc/x86_64-linux-gnu/4.8.0/cc1plus -E -quiet -v -imultilib . -imultiarch x86_64-linux-gnu -D_GNU_SOURCE abc.cc -mtune=generic -march=x86-64 -std=gnu++11 -Wall -Wextra -fpch-preprocess -o abc.ii
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc-snapshot/lib/gcc/x86_64-linux-gnu/4.8.0/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc-snapshot/lib/gcc/x86_64-linux-gnu/4.8.0/../../../../include/c++/4.8.0
 /usr/lib/gcc-snapshot/lib/gcc/x86_64-linux-gnu/4.8.0/../../../../include/c++/4.8.0/x86_64-linux-gnu/.
 /usr/lib/gcc-snapshot/lib/gcc/x86_64-linux-gnu/4.8.0/../../../../include/c++/4.8.0/backward
 /usr/lib/gcc-snapshot/lib/gcc/x86_64-linux-gnu/4.8.0/include
 /usr/local/include
 /usr/lib/gcc-snapshot/lib/gcc/x86_64-linux-gnu/4.8.0/include-fixed
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-Wall' '-Wextra' '-std=gnu++11' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
 /usr/lib/gcc-snapshot/libexec/gcc/x86_64-linux-gnu/4.8.0/cc1plus -fpreprocessed abc.ii -quiet -dumpbase abc.cc -mtune=generic -march=x86-64 -auxbase abc -Wall -Wextra -std=gnu++11 -version -o abc.s
GNU C++ (Debian 20130316-1) version 4.8.0 20130316 (experimental) [trunk revision 196694] (x86_64-linux-gnu)
	compiled by GNU C version 4.8.0 20130316 (experimental) [trunk revision 196694], GMP version 5.0.5, MPFR version 3.1.1-p2, MPC version 0.9
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
GNU C++ (Debian 20130316-1) version 4.8.0 20130316 (experimental) [trunk revision 196694] (x86_64-linux-gnu)
	compiled by GNU C version 4.8.0 20130316 (experimental) [trunk revision 196694], GMP version 5.0.5, MPFR version 3.1.1-p2, MPC version 0.9
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Compiler executable checksum: 179a73a5a5f01088a1db5a487424c1fe
abc.cc: In member function 'void Foo::Func()':
abc.cc:23:16: internal compiler error: in cp_parser_late_return_type_opt, at cp/parser.c:16970
     auto Bar() -> int {
                ^
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-snapshot/README.Bugs> for instructions.
Preprocessed source stored into /tmp/cc1Bz05T.out file, please attach this to your bugreport.

-------------------------------------------------------
Source Code:
-------------------------------------------------------

void Func() {
  struct StructDeclaredInsideFunc {
    // This is OK.
    auto Bar() -> int {
      return 1;
    }
  };
}

class Foo {
  public:
  void Func();
};

void Foo::Func() {
  struct StructDeclaredInsideClassFunc {
    // Causes:
    // g++4.7 (Debian 4.7.2-4): internal compiler error: in cp_parser_late_return_type_opt, at
    // cp/parser.c:16698
    // g++ Snapshot (4.8.0 20130316): internal compiler error: in cp_parser_late_return_type_opt, at
    // cp/parser.c:16970
    auto Bar() -> int {
      return 1;
    }
  };
}

-------------------------------------------------------
Comment 1 Richard Biener 2013-03-18 11:26:26 UTC
Confirmed.  4.6 accepts the code.
Comment 2 Jakub Jelinek 2013-03-20 12:10:17 UTC
Started with http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=175671
Comment 3 Paolo Carlini 2013-03-23 11:04:39 UTC
Fixed for 4.7.3, 4.8.1, 4.9.0.