public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/15076] New: cast to void * of parameter in call to template constructor causes compilation error
@ 2004-04-22 18:42 niemayer at isg dot de
  2004-04-22 20:21 ` [Bug c++/15076] " niemayer at isg dot de
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: niemayer at isg dot de @ 2004-04-22 18:42 UTC (permalink / raw)
  To: gcc-bugs

Try to compile the following tiny sample code with gcc 3.4.0:

-----------------------------------------------------------------------
class S { };

class X 
{
public:
	void * v;
	S s;
	
	X(void * v_, const S & s_) : v(v_), s(s_) { }
};

template <class T>
class Y : public T
{
public:
	template <typename X1, typename X2>
	Y(X1 & x1, X2 & x2) : T(x1, x2) {
		
	}
};

void test(void) {
	
	S s;
	void * v = &s;
	
	Y<X> * y1 = new Y<X>(v, s);          // works 
	Y<X> * y3 = new Y<X>(reinterpret_cast<void *>(v), s);  // works
	Y<X> * y2 = new Y<X>((void *)v, s);  // error - but why??
}
-----------------------------------------------------------------------

Only one of the three lines with "... = new Y<X>..." triggers an error, though
that and also the error message as such does not seem plausible:

templ_constr.cxx: In function `void test()':
templ_constr.cxx:30: error: no matching function for call to `Y<X>::Y(void*, S&)'
templ_constr.cxx:15: note: candidates are: Y<X>::Y(const Y<X>&)
templ_constr.cxx:18: note:                 Y<T>::Y(X1&, X2&) [with X1 = void*,
X2 = S, T = X]


Any idea what this error is about?

-- 
           Summary: cast to void * of parameter in call to template
                    constructor causes compilation error
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: niemayer at isg dot de
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


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

end of thread, other threads:[~2004-06-10 14:30 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-04-22 18:42 [Bug c++/15076] New: cast to void * of parameter in call to template constructor causes compilation error niemayer at isg dot de
2004-04-22 20:21 ` [Bug c++/15076] " niemayer at isg dot de
2004-04-22 20:36 ` pinskia at gcc dot gnu dot org
2004-04-22 21:06 ` [Bug c++/15076] [3.3/3.4/3.5 regression] result of reinterpret_cast is an lvalue bangerth at dealii dot org
2004-05-03  5:07 ` pinskia at gcc dot gnu dot org
2004-06-06  3:39 ` giovannibajo at libero dot it
2004-06-09 19:07 ` mmitchel at gcc dot gnu dot org
2004-06-10 14:27 ` cvs-commit at gcc dot gnu dot org
2004-06-10 14:27 ` cvs-commit at gcc dot gnu dot org
2004-06-10 14:30 ` mmitchel 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).