public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/24847]  New: Instantiates un-called copy constructor
@ 2005-11-14 14:06 igodard at pacbell dot net
  2005-11-14 19:32 ` [Bug c++/24847] " pinskia at gcc dot gnu dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: igodard at pacbell dot net @ 2005-11-14 14:06 UTC (permalink / raw)
  To: gcc-bugs

enum A{b,c};
template<typename T, int i, A x>
struct foo {
explicit    foo(T& t);
explicit    foo(foo<T, 0, x>);
};

int main() {
    int i;
    foo<int, 5, b> v(i);
    }


gets you:

~/ootbc/members/src$ g++ foo.cc
foo.cc: In instantiation of `foo<int, 0,  b>':
foo.cc:10:   instantiated from here
foo.cc:5: error: invalid constructor; you probably meant `foo<int, 0,  b>
(const foo<int, 0,  b>&)'

The error arises because it thinks I am instantiating "foo<T, 0,A>(foo<T, 0,
A>)", i.e. a copy constructor that is not taking a const reference argument.
But I'm not; I'm instantiating the plain constructor "foo<T, int, A>(int&)". 

The second constructor is intended to catch the case: "foo<T, 5, A>(foo<T, 0,
A>", i.e. to convert an instance of foo with second argument zero to a foo with
any other second argument. It looks like when it is expanding the argument type
of the second constructor (i.e. "foo<T, 0, A>") that it is not just parsing the
resulting template but also applying the "valid copy constructor?" check for
that type. But as that second constructor is never called by anyone it the
compiler should just syntax check it (valid) and not semantic check it (invalid
for "foo(T, 0, A)" but valid for everything else).

Ivan


-- 
           Summary: Instantiates un-called copy constructor
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: igodard at pacbell dot net


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


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

* [Bug c++/24847] Instantiates un-called copy constructor
  2005-11-14 14:06 [Bug c++/24847] New: Instantiates un-called copy constructor igodard at pacbell dot net
@ 2005-11-14 19:32 ` pinskia at gcc dot gnu dot org
  2005-11-15  0:30 ` igodard at pacbell dot net
  2005-11-23  5:21 ` bangerth at dealii dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-11-14 19:32 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2005-11-14 19:32 -------
Comeau also rejects this.  I don't understand why we are trying to instantiate
foo<int, 5, b>::foo(foo<int, 0, b>) except to try to match the constructor, so
maybe this is invalid after all.  Some one else really needs to look at this.

A weird testcase at best.


-- 


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


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

* [Bug c++/24847] Instantiates un-called copy constructor
  2005-11-14 14:06 [Bug c++/24847] New: Instantiates un-called copy constructor igodard at pacbell dot net
  2005-11-14 19:32 ` [Bug c++/24847] " pinskia at gcc dot gnu dot org
@ 2005-11-15  0:30 ` igodard at pacbell dot net
  2005-11-23  5:21 ` bangerth at dealii dot org
  2 siblings, 0 replies; 4+ messages in thread
From: igodard at pacbell dot net @ 2005-11-15  0:30 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from igodard at pacbell dot net  2005-11-15 00:30 -------
The original was much more sensible - and much bigger :-)

Ivan


-- 


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


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

* [Bug c++/24847] Instantiates un-called copy constructor
  2005-11-14 14:06 [Bug c++/24847] New: Instantiates un-called copy constructor igodard at pacbell dot net
  2005-11-14 19:32 ` [Bug c++/24847] " pinskia at gcc dot gnu dot org
  2005-11-15  0:30 ` igodard at pacbell dot net
@ 2005-11-23  5:21 ` bangerth at dealii dot org
  2 siblings, 0 replies; 4+ messages in thread
From: bangerth at dealii dot org @ 2005-11-23  5:21 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from bangerth at dealii dot org  2005-11-23 05:21 -------
The second constructor is definitely bogus, but its mere existence 
does no harm. We should only perform the check for sensibility when
we actually instantiate the second constructor.

W.


-- 

bangerth at dealii dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2005-11-23 05:21:00
               date|                            |


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


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

end of thread, other threads:[~2005-11-23  5:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-14 14:06 [Bug c++/24847] New: Instantiates un-called copy constructor igodard at pacbell dot net
2005-11-14 19:32 ` [Bug c++/24847] " pinskia at gcc dot gnu dot org
2005-11-15  0:30 ` igodard at pacbell dot net
2005-11-23  5:21 ` bangerth at dealii 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).