In my physically based renderer, I'm getting a memory corruption bug (the program crashes, and the debugger gives a bogus stack trace that's worthless). I traced it down to this SSCCE. The line with the constructor seems to be what triggers the error:
#include <cstdint>
class Foo final {
public:
uint8_t packed;
public:
inline Foo(void) : packed(0xFF) {} //causes error
inline ~Foo(void) = default;
};
static_assert(sizeof(Foo)==sizeof(uint8_t),"Implementation error!");
int main(int /*argc*/, char* /*argv*/[]) {
Foo* arr = new Foo[4]; //Tried a bunch of different sizes. All fail.
delete [] arr;
return 0;
}
The problem does not occur for MSVC or GCC, only Intel Compiler (the version of which is 16.0). But, since this is a memory corruption bug, that doesn't really mean anything. Before I submit a bug report, can someone confirm this is not me misusing C++?
Here is a premade solution demonstrating the problem. Here is the assembly.
As established in the comments, over a series of increasingly simpler examples (and corresponding edits), this is perfectly valid C++ code.
I posted a bug report on Intel's developer forum, and it has been officially confirmed as such.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With