[xsd-users] gcc warning

Boris Kolpackov boris at codesynthesis.com
Mon Oct 27 10:04:46 EDT 2008


Hi Ray,

Rizzuto, Raymond <Raymond.Rizzuto at sig.com> writes:

> In one place in my code, I want to get the id out of a constructed object, 
> and pass it to a function taking int.   I.e. essentially do this
> 
>    functionTakingAnInt(stock.get_id());
> 
> When I compile the code (gcc 3.3.3), I get this warning:
> 
> [...]
> 
> Is there a better method that prevents this warning?

This is a well-known, bogus warning in older versions of g++. 
Unfortunately I don't have access to the version that produces
this warning so I couldn't test my work-arounds (g++ 3.3.6 as 
well as 3.2.3 that I have access to don't have this bug). 

I think the following should work (besides upgrading the compiler,
of course):

functionTakingAnInt((int&)stock.get_id ());

const ReferenceDataId& id (stock.get_id ());
functionTakingAnInt(id);

Making stock const should also help. If you don't plan to modify
stock then this might be the cleanest approach.

Boris






More information about the xsd-users mailing list