public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* c++ cast bug ?
@ 2001-09-19 20:52 John Levon
  2001-09-27  5:42 ` Alexandre Oliva
  0 siblings, 1 reply; 2+ messages in thread
From: John Levon @ 2001-09-19 20:52 UTC (permalink / raw)
  To: gcc

in 3.0.1 but also in rh gcc 2.96 :

void opp_get_options(int argc, char const *argv[])
{
	...
       /* Some old version of popt needs the cast to char ** */
       optcon = poptGetContext(NULL, argc, const_cast<char **>(argv), options, 0);


compiling this c++ :

oprofpp.c:143: cannot convert `char **' to `const char **' for argument
`3' to `poptGetContext (const char *, int, const char **, const
poptOption *, int)'

how can this be right (where is implicit cast to const version of char **) ? 

if it's wrong or not, how do I fix my code to work ?

thanks
john

-- 
"If you're not part of the problem, you're part of the problem space." 

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

* Re: c++ cast bug ?
  2001-09-19 20:52 c++ cast bug ? John Levon
@ 2001-09-27  5:42 ` Alexandre Oliva
  0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Oliva @ 2001-09-27  5:42 UTC (permalink / raw)
  To: John Levon; +Cc: gcc

On Sep 20, 2001, John Levon <moz@compsoc.man.ac.uk> wrote:

> oprofpp.c:143: cannot convert `char **' to `const char **' for argument
> `3' to `poptGetContext (const char *, int, const char **, const
> poptOption *, int)'

> how can this be right (where is implicit cast to const version of char **) ? 

The argument was const_casted to char**, but the parameter has type
const char**, and there's no implicit conversion from char** to const
char**.

> if it's wrong or not, how do I fix my code to work ?

Just take the const_cast out.

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist    *Please* write to mailing lists, not to me

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

end of thread, other threads:[~2001-09-27  5:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-09-19 20:52 c++ cast bug ? John Levon
2001-09-27  5:42 ` Alexandre Oliva

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