delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/02/11/15:14:29

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Tue, 11 Feb 2003 15:16:59 -0500
From: Indiana Epilepsy and Child Neurology <BrainChild AT Skyler DOT com>
Subject: Conversion operator and new
To: cygwin AT cygwin DOT com
Reply-to: BrainChild AT Skyler DOT com
Message-id: <s4mi4vosigroccdn4l1fi9sl657conq47o@4ax.com>
MIME-version: 1.0

Greetings!

g++ produces an error "size in array new must have integral type" in
function f2.  I expected the conversion operators to convert x to
size_t, which is an integral type.  They do if I remove *either* the
const *or* the non-const version of operator size_t, and they do for
passing x to function f1 in any case.

Is this a bug?

#include	<cstddef>

struct	X
{
	operator size_t	()				{	return
2;	}
	operator size_t	()	const	{	return	3;	}
};

char	*f1	(	size_t	n	)		{	return
new	char[n];	}

char	*f2	(	const X	&x	)	{	return	new
char[x];	}

int	main	(void)					{	}

/*

$ g t.cpp -ot
t.cpp: In function `char* f2(const X&)':
t.cpp:11: size in array new must have integral type

*/
-- 
Don Stauffer, Office Manager
Indiana Epilepsy and Child Neurology, Inc.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019