Bug 178061

Summary: g++ segfaults on typename
Product: [Fedora] Fedora Reporter: Ethan Tira-Thompson <ejt>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 3   
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: 3.4.5-2 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2006-01-17 21:41:52 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
preprocessed source for the bug none

Description Ethan Tira-Thompson 2006-01-17 17:21:51 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/416.12 (KHTML, like Gecko) Safari/416.13

Description of problem:
here is the code which causes the crash:
====================
#include <vector>

template<class PredType>
void foo() {
  bar(typename std::back_insert_iterator<std::vector<int> >(baz));
}
====================
Removing the 'typename' avoids the segfault

Version-Release number of selected component (if applicable):
gcc 3.4.2

How reproducible:
Always

Steps to Reproduce:
1.
2.
3.
  

Additional info:

Comment 1 Ethan Tira-Thompson 2006-01-17 18:42:12 UTC
Created attachment 123317 [details]
preprocessed source for the bug

Comment 2 Ethan Tira-Thompson 2006-01-17 18:45:42 UTC
Please note that removing the 'typename' keyword simply avoids the crash -- I
realize that the code shown will then result in a compilation error.  The key is
that it should give the error and not segfault.

If that is resolved, I expect it would successfully compile if the full code
were being compiled instead of this minimal snippet.

Comment 3 Jakub Jelinek 2006-01-17 21:41:52 UTC
g++ -v; g++ 178061.ii
Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.5/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-java-awt=gtk --host=i386-redhat-linux
Thread model: posix
gcc version 3.4.5 20051201 (Red Hat 3.4.5-2)
foo.cc: In function `void foo()':
foo.cc:5: error: `baz' was not declared in this scope
foo.cc:5: error: there are no arguments to `bar' that depend on a template
parameter, so a declaration of `bar' must be available
foo.cc:5: error: (if you use `-fpermissive', G++ will accept your code, but
allowing the use of an undeclared name is deprecated)

I don't have FC3 gcc around to check it (FC3 support has been moved to Fedora
Legacy already), but as you can see with the latest GCC 3.4.x-RH this is not
reproducible, neither I can reproduce it with GCC 4.0.x (FC4) nor GCC 4.1.x
(rawhide).  But even latest FC3 gcc is gcc-3.4.4-2.fc3, so it is quite likely
it is fixed there too.