Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 89911 - gcc segfault in default template argument processing
Summary: gcc segfault in default template argument processing
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] GCC Porting (show other bugs)
Hardware: x86 Linux
: High normal (vote)
Assignee: Please assign to toolchain
URL: http://gcc.gnu.org/bugzilla/show_bug....
Whiteboard: 4.0.2-r3
Keywords:
Depends on:
Blocks:
 
Reported: 2005-04-21 05:01 UTC by philippe amarenco
Modified: 2005-12-21 22:47 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description philippe amarenco 2005-04-21 05:01:45 UTC
following is the code that segfaults.
when using the first version of "helper" it works nicely.


#include <iostream>

typedef char present_t;
typedef struct { char a[2]; } absent_t;

template <typename T> T& MakeT();

template <typename T>
struct test
{
//   template <typename U, int (U::*f)(int n) = &U::operator[]>
//   struct helper{};

  template <typename U, int N = sizeof (MakeT<U>().operator[](0))>
  struct helper{};

  template <typename U>
  static absent_t is_here(...);

  template <typename U>
  static present_t is_here(helper<U>*);

  enum { ret = (sizeof(is_here<T>(0)) == sizeof(present_t)) };
};

struct A { };
struct B { int operator[](int n) { return n; } };

struct X : public A { };
struct Y : public B { };

int main()
{
  std::cout << "A has [] : " << test<A>::ret << std::endl;
  std::cout << "B has [] : " << test<B>::ret << std::endl;

  std::cout << "X:A has [] : " << test<X>::ret << std::endl;
  std::cout << "Y:B has [] : " << test<Y>::ret << std::endl;
}


g++ -W -Wall has_methode_in_hierarchy.cc
has_methode_in_hierarchy.cc:21: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://bugs.gentoo.org/> for instructions.


# g++ --version
g++ (GCC) 3.4.3-20050110 (Gentoo Linux 3.4.3.20050110, ssp-3.4.3.20050110-0, pie-8.7.7)
Comment 1 Mark Loeser (RETIRED) gentoo-dev 2005-12-21 22:47:03 UTC
Will be included in the next 4.0.2 tarball.  If upstream backports this to 3.4, I'll add it to 3.4.5 at that time.