[Bug c++/36364] New: [4.1/4.2/4.3/4.4 Regression] Problem with -frepo

jakub at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Thu May 29 09:45:00 GMT 2008


template <typename C> struct A
{
  static void assign (C &c1, const C &c2) { c1 = c2; }
};

template <typename C, typename T> struct B
{
  struct D
  {
    static const C terminal;
    static unsigned long stor[];
    static D &empty_rep ()
    {
      void *p = reinterpret_cast <void *>(&stor);
      return *reinterpret_cast <D *>(p);
    }
    void test (unsigned long n)
    {
      T::assign (this->refdata ()[n], terminal);
    }
    C *refdata () throw ()
    {
      return reinterpret_cast <C *>(this + 1);
    }
  };
  C *dataplus;
  C *data () const { return dataplus; }
  D *rep () const { return &((reinterpret_cast < D * >(data ()))[-1]); }
  static D & empty_rep () { return D::empty_rep (); }
  B () : dataplus (empty_rep ().refdata ()) { }
  ~B () { }
  void push_back (C c) { rep ()->test (10); }
};

template <typename C, typename T> const C B <C, T>::D::terminal = C ();
template <typename C, typename T> unsigned long B <C, T>::D::stor[64];

int
main ()
{
  B <char, A <char> > s;
  s.push_back ('a');
}

g++ -c -frepo d.C
g++ -frepo -o d{,.o}
results in:
d.o: In function `B<char, A<char> >::D::test(unsigned long)':
d.C:(.text+0xc9): undefined reference to `B<char, A<char> >::D::terminal'
collect2: ld returned 1 exit status

3.4 worked fine.


-- 
           Summary: [4.1/4.2/4.3/4.4 Regression] Problem with -frepo
           Product: gcc
           Version: 4.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jakub at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36364



More information about the Gcc-bugs mailing list