public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/25153]  New: Bug in name lookup in template -- 4.0 regression against 3.4
@ 2005-11-29 14:35 richard at ex-parrot dot com
  2005-11-29 15:19 ` [Bug c++/25153] [4.0 Regression] " pinskia at gcc dot gnu dot org
  0 siblings, 1 reply; 2+ messages in thread
From: richard at ex-parrot dot com @ 2005-11-29 14:35 UTC (permalink / raw)
  To: gcc-bugs

The code below compiles fine with gcc 3.3.1 and 3.4.0 (and does the right
thing); it produces a compile time error in 4.0.2.  Lookup of the << operator
in the definition of serializable::impl<X>::value fails when it is instatiated
via the bar or baz templates but succeeds when instantiated via the foo
template.  (Use of the bar or baz templates will succeed if instantation has
alread occured.)

Curiously, the bug seems very specific -- a number of very similar pieces of
code in 4.0.2's <tr1/type_traits> header compile correctly.

// --------------------

extern "C" int printf( char const*, ... );

namespace std2 {
  class ostream { void* ptr; };
  class string;

  ostream& operator<<( ostream&, string const& );
} 

namespace serializable {
  struct two { std2::ostream a, b; };
  template <class U, class V> two operator<<(U&, V const&);

  template <class T>
  struct impl {
    static T const& make();
    static std2::ostream& stream();
    static const bool value 
      = sizeof( stream() << make() ) == sizeof(std2::ostream);
  };
}

template <bool V>     struct foo { foo() { printf("%d\n", V); } };
template <typename T> struct baz : foo< T::value > {};
template <typename T> struct bar : baz< serializable::impl<T> > {};
struct X {};

int main() {
  bar< X >();  // -- Fails
  baz< serializable::impl<X> >(); // -- Fails
  foo< serializable::impl<X>::value >(); // -- Succeeds
  baz< serializable::impl<X> >(); // -- Succeeds 
  bar< X >();  // -- Succeeds
}

// Expected output: 0 0 0 0 0


-- 
           Summary: Bug in name lookup in template -- 4.0 regression against
                    3.4
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: richard at ex-parrot dot com


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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c++/25153] [4.0 Regression] Bug in name lookup in template -- 4.0 regression against 3.4
  2005-11-29 14:35 [Bug c++/25153] New: Bug in name lookup in template -- 4.0 regression against 3.4 richard at ex-parrot dot com
@ 2005-11-29 15:19 ` pinskia at gcc dot gnu dot org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-11-29 15:19 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2005-11-29 15:19 -------
Fixed in 4.0.3 already.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED
            Summary|Bug in name lookup in       |[4.0 Regression] Bug in name
                   |template -- 4.0 regression  |lookup in template -- 4.0
                   |against 3.4                 |regression against 3.4
   Target Milestone|---                         |4.0.3
            Version|unknown                     |4.0.2


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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-11-29 15:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-29 14:35 [Bug c++/25153] New: Bug in name lookup in template -- 4.0 regression against 3.4 richard at ex-parrot dot com
2005-11-29 15:19 ` [Bug c++/25153] [4.0 Regression] " pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).