Skip to content

Commit d8078c7

Browse files
committed
Suppress bogus C4738 from MSVC.
Our trick to extract a big-endian IEEE floating-point number from a packet confuses MSVC into thinking we're doing something we're not doing, or maybe just that we might do so somewhere that it can't see. Suppress the resulting warning. This should fix issue #1318.
1 parent a88068e commit d8078c7

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

CMakeLists.txt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,6 +1158,39 @@ if(EXISTS ${CMAKE_SOURCE_DIR}/.devel OR EXISTS ${CMAKE_BINARY_DIR}/.devel)
11581158
# file in tcpdump, gets a warning.
11591159
#
11601160
check_and_add_compiler_option(-wd4324)
1161+
#
1162+
# Suppress warnings about a "possible loss of performance"
1163+
# due to "storing 32-bit float result in memory" in the
1164+
# "fetch a 32-bit floating-point variable, in a particular
1165+
# byte order, from a packet" routines.
1166+
#
1167+
# What those routines do is fetch a 32-bit unsigned integral
1168+
# value in the appropriate byte order, store it into the
1169+
# "32-bit unsigned integer value" member of a union, and then
1170+
# return the "32-bit floating-point value" member of that union,
1171+
# in order to reinterpret the bits of the value as if it were
1172+
# an IEEE floating-point value. (Yes, we know, VAX floating
1173+
# point; at least the IBM mainframes have supported IEEE
1174+
# floating-point since the G4 S/390s.)
1175+
#
1176+
# The Microsoft page on that warning:
1177+
#
1178+
# https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-3-c4738?view=msvc-170
1179+
#
1180+
# says that
1181+
#
1182+
# C4738 warns that the result of an assignment, cast, passed
1183+
# argument, or other operation may need to be rounded or
1184+
# that the operation ran out of registers and needed to
1185+
# use memory (spilling). This can result in performance loss.
1186+
#
1187+
# That suggests that the performance issues would be due to
1188+
# conversion between double and float, which we're not doing,
1189+
# or due to a calculation somehow running out of registers,
1190+
# but we're not doing a calculation. Thus, we just suppress
1191+
# the warning.
1192+
#
1193+
check_and_add_compiler_option(-wd4738)
11611194
else()
11621195
#
11631196
# Other compilers, including MSVC with a Clang front end and

0 commit comments

Comments
 (0)