[cfe-commits] [PATCH 11/15] Fix Casting

Dmitri Gribenko gribozavr at gmail.com
Fri Jan 11 10:09:04 PST 2013


On Fri, Jan 11, 2013 at 8:02 PM,  <dag at cray.com> wrote:
> Dmitri Gribenko <gribozavr at gmail.com> writes:
>
>> On Thu, Jan 10, 2013 at 9:12 PM, David Greene <dag at cray.com> wrote:
>>> Use const_cast<> to avoid a cast-away-const error.
>>
>> Maybe a helper function template would be better (for all except the
>> first)?  Argyrios?
>
> Hmm...I think const_cast is useful because it's a red flag.  I don't
> think we should be hiding that as it can indicate a design issue.

That's right, const_cast is a red flag, but in these places the cast
is always safe, since we are storing pointers to AST nodes (which are
always allocated non-const) into a C struct with void* pointer just to
pass the struct to C-land.

Dmitri

-- 
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/



More information about the cfe-commits mailing list