This is an archive of the discontinued LLVM Phabricator instance.

Add documentation for -fno-strict-aliasing
AcceptedPublic

Authored by simonbyrne on Mar 2 2017, 8:20 AM.

Details

Summary

This is probably good to document, as the behaviour of -fstrict-aliasing differs from gcc in a quite important way (see https://bugs.llvm.org//show_bug.cgi?id=31928) .

Diff Detail

Event Timeline

simonbyrne created this revision.Mar 2 2017, 8:20 AM
hfinkel added a subscriber: hfinkel.
hfinkel added inline comments.
docs/UsersManual.rst
1106

Capitalize Unlike.

hans edited edge metadata.Mar 2 2017, 8:35 AM

+1 for documenting this, but I have to leave it to the language lawyers for how to fomulate it.

Enables/disables the strict aliasing assumption, which assumes that objects of different types do not share the same location in memory.

I think it needs to say incompatible types at least (and char and unsigned char are also special). And isn't it really about pointers -- the compiler assumes that when dereferncing two pointers of incompatible types, those pointers do not refer to the same memory?

clang does not allow "type-punning" by writing and reading from different union members

I thought clang does allow type-punning through unions, as long as it's in a single function, but that it fails when things get more complicated.

+dannyb who enjoys this stuff ;)

dberlin edited edge metadata.Mar 2 2017, 9:00 AM
In D30538#690699, @hans wrote:

+1 for documenting this, but I have to leave it to the language lawyers for how to fomulate it.

Enables/disables the strict aliasing assumption, which assumes that objects of different types do not share the same location in memory.

I think it needs to say incompatible types at least (and char and unsigned char are also special). And isn't it really about pointers -- the compiler assumes that when dereferncing two pointers of incompatible types, those pointers do not refer to the same memory?

clang does not allow "type-punning" by writing and reading from different union members

I thought clang does allow type-punning through unions, as long as it's in a single function, but that it fails when things get more complicated.

The limitation is really "union accesses must be visibly through a union, and if you try to trick the compiler, you will lose".
That is what we meant to allow, it just is still broken *anyway*

+dannyb who enjoys this stuff ;)

You are so mean :)

dim accepted this revision.May 26 2017, 10:48 AM

LGTM, though it would be nice if we implemented gcc's extension for this at some point... ;)

This revision is now accepted and ready to land.May 26 2017, 10:48 AM

Fix capitalisation.

Hi, is this commit still valid? Why hasn't it been pushed?

Herald added a project: Restricted Project. · View Herald TranscriptJul 1 2022, 12:44 AM

i have no idea. It looks like it may have been resolved in https://reviews.llvm.org/rL303851? In that case, the NOTE should be removed.