public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/42466]  New: Multiple instantiations of template constructor fail
@ 2009-12-22 18:05 apatterno at gmail dot com
  2009-12-22 18:22 ` [Bug c++/42466] " pinskia at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: apatterno at gmail dot com @ 2009-12-22 18:05 UTC (permalink / raw)
  To: gcc-bugs

The test code:

template<class IntT, IntT X>
struct A
{
    IntT val_;

    A() : val_(X) {}
    A(IntT arg) : val_(arg) {}

    template<IntT X2>
    A(const A<IntT, X2>& other) : val_(other.val_) {}
};

int main(int argc, char** argv)
{
    A<int, 42> a;
    A<int, 100> b = a;

    A<unsigned, 42u> c;
    A<unsigned, 100u> d = c;

    A<long, 42l> e;
    A<long, 100l> f = e;
}

fails to compile on gcc 4.3.2:

case.cpp: In function 'int main(int, char**)':
case.cpp:19: error: conversion from 'A<unsigned int, 42u>' to non-scalar type
'A<unsigned int, 100u>' requested
case.cpp:22: error: conversion from 'A<long int, 42l>' to non-scalar type
'A<long int, 100l>' requested

The first conversion is OK, but the other two conversions are being flagged as
errors.  Even if I were to put the conversions in a different order, the same
results... first one is OK, other two fail.


-- 
           Summary: Multiple instantiations of template constructor fail
           Product: gcc
           Version: 4.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: apatterno at gmail dot com
 GCC build triplet: i686-pc-cygwin
  GCC host triplet: i686-pc-cygwin
GCC target triplet: i686-pc-cygwin


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


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

end of thread, other threads:[~2009-12-31 15:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-22 18:05 [Bug c++/42466] New: Multiple instantiations of template constructor fail apatterno at gmail dot com
2009-12-22 18:22 ` [Bug c++/42466] " pinskia at gcc dot gnu dot org
2009-12-22 18:29 ` paolo dot carlini at oracle dot com
2009-12-22 19:21 ` jason at gcc dot gnu dot org
2009-12-22 23:17 ` jason at gcc dot gnu dot org
2009-12-31 15:48 ` rguenth 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).