[llvm] r273627 - [MachOYAML] Use a temporary to avoid gcc strict-aliasing warning

Chris Bieneman via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 23 16:01:47 PDT 2016


Author: cbieneman
Date: Thu Jun 23 18:01:47 2016
New Revision: 273627

URL: http://llvm.org/viewvc/llvm-project?rev=273627&view=rev
Log:
[MachOYAML] Use a temporary to avoid gcc strict-aliasing warning

GCC complains about this with -Wstrict-aliasing. Using a temporary here should prevent the warning.

Modified:
    llvm/trunk/lib/ObjectYAML/MachOYAML.cpp

Modified: llvm/trunk/lib/ObjectYAML/MachOYAML.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ObjectYAML/MachOYAML.cpp?rev=273627&r1=273626&r2=273627&view=diff
==============================================================================
--- llvm/trunk/lib/ObjectYAML/MachOYAML.cpp (original)
+++ llvm/trunk/lib/ObjectYAML/MachOYAML.cpp Thu Jun 23 18:01:47 2016
@@ -182,8 +182,10 @@ void mapLoadCommandData<MachO::dylinker_
 
 void MappingTraits<MachOYAML::LoadCommand>::mapping(
     IO &IO, MachOYAML::LoadCommand &LoadCommand) {
-  IO.mapRequired(
-      "cmd", (MachO::LoadCommandType &)LoadCommand.Data.load_command_data.cmd);
+  MachO::LoadCommandType TempCmd = static_cast<MachO::LoadCommandType>(
+      LoadCommand.Data.load_command_data.cmd);
+  IO.mapRequired("cmd", TempCmd);
+  LoadCommand.Data.load_command_data.cmd = TempCmd;
   IO.mapRequired("cmdsize", LoadCommand.Data.load_command_data.cmdsize);
 
 #define HANDLE_LOAD_COMMAND(LCName, LCValue, LCStruct)                         \




More information about the llvm-commits mailing list