On Tue, Feb 06, 2007 at 01:53:44PM -0800, Silvius Rus wrote: > I am implementing -Wstrict-aliasing by catching simple cases in the > frontend and more complex ones in the backend. The frontend mechanism > is tree pattern matching. The backend one uses flow-sensitive points-to > information. > > I want to avoid duplicate warnings. I thought of a few ways, but none > seems perfect. Can you please advise which of the following I should > choose, suggest alternatives, or let me know if a solution exists.
All strict-aliasing violations involve accessing an object as the wrong type. However, there are some objects that can be accessed as any type without a violation, e.g. the result of malloc (or, more generally, void* in C). If you have a way to flag an object as "can alias to anything" once you warn about an error, you won't get duplicate warnings. If the exact same location is accessed incorrectly at another point, then the user might fix the first message and then see the second one, but this still might be better than a cascade of repetitive complaints (particularly for a tricky cast in a macro, which is really one error even if used repetitively).