[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gcl-devel] Type-punning
From: |
Camm Maguire |
Subject: |
[Gcl-devel] Type-punning |
Date: |
08 Jul 2003 19:27:37 -0400 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 |
Greetings! OK, I've fixed the strict-aliasing/type-punning errors
gcc-3.3 reports with default optimization. To refresh our memories,
strict-aliasing is an optimization which relies on the ability to
separate memory locations for objects of different type. One quick
and dirty response for GCL would be to add -fno-strict-aliasing to the
flags, but I like to take advantage of all the optimization we can
get!
In any case, I want to make sure I just haven't fooled the warning
code in gcc. The fixes fall into two categories. In the o/
directory, I've defined explicit unions containing both the input and
output types, and used union element assignments to do the type
conversion. I'm pretty confident about this.
In the lsp/ et. al. directories, we cast pointers in the middle of a
function call in two places, for example:
parse_key_rest_new(V203,narg,Vcs +3,(struct key *)&LI26key,first,ap);
static void LnkT35(){ call_or_link(VV[35],(void **)&Lnk35);} /*
ARRAY-IN-BOUNDS-P */
My solution here was to have the compiler write instead
parse_key_rest_new(V203,narg,Vcs +3,(struct key *)(void *)&LI26key,first,ap);
static void LnkT35(){ call_or_link(VV[35],(void **)(void *)&Lnk35);} /*
ARRAY-IN-BOUNDS-P */
with which there are no warnings. Of course this could have been done
in several other ways. Is this legit?
Take care,
--
Camm Maguire address@hidden
==========================================================================
"The earth is but one country, and mankind its citizens." -- Baha'u'llah
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gcl-devel] Type-punning,
Camm Maguire <=