summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorEllie Hermaszewska <ellieh@nvidia.com>2023-08-16 04:01:11 +0800
committerGitHub <noreply@github.com>2023-08-15 13:01:11 -0700
commit134f27df2695de086472ce70b1197b622fabc147 (patch)
tree6cc74b180bfba8daf49dab6952730c4d4c9782af /source
parent3d7552582bb4d4e330b1e90bcdced046cebd140c (diff)
Disable strict aliasing for gcc (#3105)
Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'source')
-rw-r--r--source/compiler-core/slang-gcc-compiler-util.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/source/compiler-core/slang-gcc-compiler-util.cpp b/source/compiler-core/slang-gcc-compiler-util.cpp
index c4354f40e..d8df9714a 100644
--- a/source/compiler-core/slang-gcc-compiler-util.cpp
+++ b/source/compiler-core/slang-gcc-compiler-util.cpp
@@ -470,6 +470,11 @@ static SlangResult _parseGCCFamilyLine(SliceAllocator& allocator, const UnownedS
cmdLine.addArg("-std=c++17");
}
+ // Our generated code very often casts between dissimilar types with the
+ // knowledge that they have the same representation. This is strictly
+ // speaking UB, and GCC 10+ is happy to take advantage of this, stop it.
+ cmdLine.addArg("-fno-strict-aliasing");
+
// TODO(JS): Here we always set -m32 on x86. It could be argued it is only necessary when creating a shared library
// but if we create an object file, we don't know what to choose because we don't know what final usage is.
// It could also be argued that the platformKind could define the actual desired target - but as it stands