|
From: <man...@us...> - 2014-11-01 21:51:17
|
Revision: 4534
http://sourceforge.net/p/modplug/code/4534
Author: manxorist
Date: 2014-11-01 21:51:00 +0000 (Sat, 01 Nov 2014)
Log Message:
-----------
[Fix] Avoid undefined behaviour (found with clang undefined behaviour sanitizer): Declaring an over-aligned type with alignas(32) causes the compiler to legally assume all objects of that type to have that very alignment. Additionally, it also causes all types containing this type to be that much over-aligned. Calling operator new on such an over-aligned type is undefined behaviour, as is accessing an object that is mis-aligned- The purpose of desiring alignment of struct ModChannel is only to have each consecutive item in an array start at a cacheline. The gain is questionable as we are not risking any kind of false sharing here (everything is single-threaded) and there is even the possibility of performance decrease due to alignment because of added padding and thus cache pressure increase. In order to keep things simple, just unconditianlly remove the extended alignemnt instead of doing custom aligned allocation for every CSoundFile object.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/ModChannel.h
trunk/OpenMPT/soundlib/Sndfile.h
Modified: trunk/OpenMPT/soundlib/ModChannel.h
===================================================================
--- trunk/OpenMPT/soundlib/ModChannel.h 2014-11-01 21:14:29 UTC (rev 4533)
+++ trunk/OpenMPT/soundlib/ModChannel.h 2014-11-01 21:51:00 UTC (rev 4534)
@@ -14,12 +14,8 @@
class CSoundFile;
-#if MPT_COMPILER_MSVC
-#pragma warning(disable:4324) //structure was padded due to __declspec(align())
-#endif
-
// Mix Channel Struct
-struct ALIGN(32) ModChannel
+struct ModChannel
{
// Envelope playback info
struct EnvInfo
@@ -194,7 +190,7 @@
// Default pattern channel settings
-struct ALIGN(32) ModChannelSettings
+struct ModChannelSettings
{
FlagSet<ChannelFlags> dwFlags; // Channel flags
uint16 nPan; // Initial pan (0...256)
@@ -217,8 +213,4 @@
}
};
-#if MPT_COMPILER_MSVC
-#pragma warning(default:4324) //structure was padded due to __declspec(align())
-#endif
-
OPENMPT_NAMESPACE_END
Modified: trunk/OpenMPT/soundlib/Sndfile.h
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.h 2014-11-01 21:14:29 UTC (rev 4533)
+++ trunk/OpenMPT/soundlib/Sndfile.h 2014-11-01 21:51:00 UTC (rev 4534)
@@ -241,11 +241,6 @@
};
-#if MPT_COMPILER_MSVC
-#pragma warning(disable:4324) //structure was padded due to __declspec(align())
-#endif
-
-
//==============
class CSoundFile
//==============
@@ -917,11 +912,7 @@
};
-#if MPT_COMPILER_MSVC
-#pragma warning(default : 4324) //structure was padded due to __declspec(align())
-#endif
-
extern const char szNoteNames[12][4];
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|