public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "gianni at mariani dot ws" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/31512]  New: function template with member reference compile failure
Date: Mon, 09 Apr 2007 06:34:00 -0000	[thread overview]
Message-ID: <bug-31512-2828@http.gcc.gnu.org/bugzilla/> (raw)

The code below has 3 ways of declaring the template member function
ObjInitSelDot().  One of them performs as desired, the other two do not. 
Comeau compiles all of them (albeit with a silly warning).

As far as I can tell, all three should compile.

template <typename T>
struct InitObject
{
    private:

    struct xA {};
    struct xB : xA {};

    template <int w_size>
    struct Detect;

    struct NoMemb { char a[1]; };
    struct Memb_MemberA { char a[2]; };


    template <typename U>
    inline static Memb_MemberA ObjInitSelDot(
// 3 different signatures - one works 2 fail under gcc 4.1.1
//        U & obj, xB * b, Detect< sizeof(U().MemberA) > * = 0 // ?? bug
//        U & obj, xB * b, Detect< sizeof(&U::MemberA) > * = 0 // Works
        // also ICE's on gcc 4.0.0 and earlier
        U & obj, xB * b, Detect< sizeof(((U*)0)->MemberA) > * = 0 // ?? bug
    );

    template <typename U>
    inline static NoMemb ObjInitSelDot(
        U & obj, xA * b
    );

    public:

    inline int ObjTest()
    {
        typedef xB * bp;

        T   obj = T();

        return sizeof( ObjInitSelDot( obj, bp() ) );

    }
};


/////////// test code

struct A
{
    int a;
    char x[10];
};


struct B
{
    int MemberA;
    char x[15];
};


int main()
{
    InitObject<A>().ObjTest();
    InitObject<B>().ObjTest();
}


-- 
           Summary: function template with member reference compile failure
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gianni at mariani dot ws
 GCC build triplet: i386-redhat-linux
  GCC host triplet: i386-redhat-linux
GCC target triplet: i386-redhat-linux


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


             reply	other threads:[~2007-04-09  6:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-09  6:34 gianni at mariani dot ws [this message]
2007-04-09 12:51 ` [Bug c++/31512] " gianni at mariani dot ws
2010-04-28 18:24 ` redi at gcc dot gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-31512-2828@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).