On Fri, May 05, 2006 at 09:31:14PM +0200, Abdelrazak Younes wrote:
> No it is char const * issue. I said remove the const and it will be all 
> right:
> 
> char * foo = codec->fromUnicode(str);
> return foo[0];
> 
> This should work on VC++ and gcc. 

This is undefined behaviour.

The temporary QCString object created as return value of 'fromUnicode'
will be destroyed at the end of the full expression, i.e. basically at
the semicolon in the first line.

So 'foo' points to nirvana immediately after its initialization.

Using it afterwards is wrong. 

Andre'

Reply via email to