[openib-general] Re: [PATCH] Opensm - ignore strict-aliasing warning

Hal Rosenstock halr at voltaire.com
Thu Sep 22 05:18:24 PDT 2005


Hi Yael,

On Thu, 2005-09-22 at 02:05, Yael Kalka wrote:
> Hi Hal,
> 
> I saw that you didn't add this patch yet.

No, I didn't as I responded to your email on this patch and hadn't heard
back until now.

> Using the -fno-strict-aliasing falg avoids the compiler from doing some optimizations that might cause the strict aliasing
> bugs. So this is a fix, and not a workaround to remove the warnings.
> I agree that it is not the best fix. It is better to fix the code in such a way that will enable these optimizations too.
> I can look into it and have a better fix, but it will take some time.
> Until then, this fix should be added, since currently we can produce code that might have these problems in it.

OK. That seems safer. info gcc is unclear on whether it breaks generated
code. It is only a warning.

`-Wstrict-aliasing'
This option is only active when `-fstrict-aliasing' is active. It
warns about code which might break the strict aliasing rules that
the compiler is using for optimization. The warning does not catch
all cases, but does attempt to catch the more common pitfalls. It
is included in `-Wall'.

`-fstrict-aliasing'
Allows the compiler to assume the strictest aliasing rules
applicable to the language being compiled. For C (and C++), this
activates optimizations based on the type of expressions. In
particular, an object of one type is assumed never to reside at
the same address as an object of a different type, unless the
types are almost the same. For example, an `unsigned int' can
alias an `int', but not a `void*' or a `double'. A character type
may alias any other type.

> Here is the patch again (in case you lost it along the mails....)

Applied.

Shouldn't -fno-strict-aliasing be added to opensm_CXXFLAGS as well ?

-- Hal





More information about the general mailing list