From: William S F. <ws...@fu...> - 2011-09-25 12:10:19
|
On 22 September 2011 18:23, Simmons, Aaron <asi...@ro...> wrote: >> What would be best would be for swig to generate code that *will not compile* when >> strict aliasing is on. Some kind of #ifdef check with an #error. >> Tho I'm not sure if gcc has a macro that can be checked against. > > Even better would be to force strict aliasing to be off by using a pragma: > #pragma GCC optimize "no-strict-aliasing" > > Then the code would always work and no-one would need to be surprised. GCC provides warnings about breaking strict aliasing rules. I'm interested to know if you overlooked these, because the warnings are telling you about the problem. IIRC earlier versions of gcc-4 put in optimizations but did not warn about them, but later versions are better at providing the warning when performing the optimization. Generating code that will not compile if strict aliasing optimization is turned on, as you suggested, would be a better in my opinion as users might want aliasing optimization in other areas of code pulled in by the wrapper file. Can you find a way to do this? -Werror -Wstrict-aliasing is of course another option, but would need to be provided by the user. William |