public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/6451: function template argument deduction wrong
@ 2002-04-25  7:26 Jens.Maurer
  0 siblings, 0 replies; 5+ messages in thread
From: Jens.Maurer @ 2002-04-25  7:26 UTC (permalink / raw)
  To: gcc-gnats


>Number:         6451
>Category:       c++
>Synopsis:       function template argument deduction wrong
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Thu Apr 25 07:26:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Jens Maurer
>Release:        3.0.4 and 3.2 20020423 (experimental)
>Organization:
>Environment:
Linux 2.4.17
>Description:
The attached program gives errors with gcc 3.0.4, although
according to ISO C++ section 14.8.2p2, only type deduction
should fail, so the other overload should be taken.

[...]
template-deduct-fail-datamember.cc: In instantiation of `has_int_data_x<X1>':
template-deduct-fail-datamember.cc:38:   instantiated from here
template-deduct-fail-datamember.cc:17: invalid use of undefined type `struct 
   has_int_data_x<X1>'
template-deduct-fail-datamember.cc:8: forward declaration of `struct 
   has_int_data_x<X1>'
[...]

It even produces an internal error with 3.2 20020423 (as 
a regression from 3.0.4):

Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions.
jmaurer@gigue:~/C++/ISO/Curacao/htdocs/demo > /opt/exp/gcc/bin/g++ template-deduct-fail-datamember.cc
>How-To-Repeat:
#include <iostream>

struct small_t { int m[1]; };
struct large_t { int m[20]; };

// find if a class has a data member (of a given type)

template<class T> struct has_int_data_x {
    private:
        template<class U> struct helper {
            template<int U::*> struct inner { };
        };
        template<class U> static small_t check(typename helper<U>::template
inner<&U::x>*);
        template<class U> static large_t check(...);
    public:
        static const bool value = sizeof(check<T>(0)) == sizeof(small_t);
};

template<class T> const bool has_int_data_x<T>::value;

struct X1
{
  int x;
};

struct X2
{
  double x;
};

struct X3
{
  int y;
};

int main() {
    std::cout << has_int_data_x<X1>::value
              << has_int_data_x<X2>::value
              << has_int_data_x<X3>::value << std::endl;
    return 0;
}

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


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

* Re: c++/6451: function template argument deduction wrong
@ 2003-01-23  1:30 bangerth
  0 siblings, 0 replies; 5+ messages in thread
From: bangerth @ 2003-01-23  1:30 UTC (permalink / raw)
  To: Jens.Maurer, gcc-bugs, gcc-prs, lerdsuwa

Synopsis: function template argument deduction wrong

State-Changed-From-To: analyzed->closed
State-Changed-By: bangerth
State-Changed-When: Thu Jan 23 01:30:37 2003
State-Changed-Why:
    A nice little template metaprogramming gem.
    
    I extracted PR 9259 a week or so ago from practically the
    same code. It has a much simpler testcase, so I close this
    one and keep the other one open, although this one is the
    older one.
    
    W.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=6451


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

* Re: c++/6451: function template argument deduction wrong
@ 2002-10-26  2:12 lerdsuwa
  0 siblings, 0 replies; 5+ messages in thread
From: lerdsuwa @ 2002-10-26  2:12 UTC (permalink / raw)
  To: Jens.Maurer, gcc-bugs, gcc-prs, lerdsuwa, nobody

Synopsis: function template argument deduction wrong

Responsible-Changed-From-To: unassigned->lerdsuwa
Responsible-Changed-By: lerdsuwa
Responsible-Changed-When: Sat Oct 26 02:12:58 2002
Responsible-Changed-Why:
    Under investigation.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=6451


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

* Re: c++/6451: function template argument deduction wrong
@ 2002-09-15  5:07 nathan
  0 siblings, 0 replies; 5+ messages in thread
From: nathan @ 2002-09-15  5:07 UTC (permalink / raw)
  To: Jens.Maurer, gcc-bugs, gcc-prs, nobody

Synopsis: function template argument deduction wrong

State-Changed-From-To: open->analyzed
State-Changed-By: nathan
State-Changed-When: Sun Sep 15 05:07:55 2002
State-Changed-Why:
    confirmed.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=6451


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

* Re: c++/6451: function template argument deduction wrong
@ 2002-05-20 12:16 Jens Maurer
  0 siblings, 0 replies; 5+ messages in thread
From: Jens Maurer @ 2002-05-20 12:16 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/6451; it has been noted by GNATS.

From: Jens Maurer <Jens.Maurer@gmx.net>
To: gcc-gnats@gcc.gnu.org, gcc-prs@gcc.gnu.org,
 	Jens.Maurer@gmx.net, gcc-bugs@gcc.gnu.org, nobody@gcc.gnu.org
Cc:  
Subject: Re: c++/6451: function template argument deduction wrong
Date: Mon, 20 May 2002 21:06:35 +0200

 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=6451
 
 There's some discussion in core issue 339 regarding this problem.
 
 http://wwwold.dkuug.dk/JTC1/SC22/WG21/docs/cwg_active.html#339
 
 Still, I'd say an internal compiler error (for 3.2) is not good.
 
 Jens Maurer


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

end of thread, other threads:[~2003-01-23  1:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-25  7:26 c++/6451: function template argument deduction wrong Jens.Maurer
2002-05-20 12:16 Jens Maurer
2002-09-15  5:07 nathan
2002-10-26  2:12 lerdsuwa
2003-01-23  1:30 bangerth

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).