Skip to content

Instantly share code, notes, and snippets.

View marzer's full-sized avatar
🌠
Yeet

Mark Gillard marzer

🌠
Yeet
View GitHub Profile
@marzer
marzer / msvc_inlining_bug.cpp
Last active July 4, 2019 16:11
MSVC inlining bug
//compiled using VS 2019 latest, v141 toolset
//flags: /fp:fast /O2 /permissive- /std:c++latest /utf-8 /volatile:iso /Zc:__cplusplus /bigobj /Zc:inline /Zc:throwingNew /Gm- /Ot /arch:AVX2 /Gd /Oy /Oi /GS- /Qpar-
#include <cstdint>
#include <cstddef>
#include <cmath>
#include <array>
#define ACH_ALWAYS_INLINE __forceinline //changing this to __declspec(noinline) 'fixes' the issue
#define ACH_ASSUME(cond) __assume(cond)
//godbolt: https://godbolt.org/z/6Ffp3J
#include <cstdint>
#include <utility>
using namespace std;
template <typename T, size_t N>
class Test
{
private:
// godbolt: https://godbolt.org/z/AfIXAD
#include <iostream>
#define MSVC_BUG 1
struct A
{
static constexpr int flag = 1;
};
struct B
@marzer
marzer / ice_vs_15.9.4.cpp
Last active December 27, 2018 18:58
Repro of an internal compiler error in Visual Studio 2017 15.9.4
// compiled in x64, Release with:
// /std:c++latest /permissive- /arch:AVX2 /fp:except- /Qpar- /GF /GS- /O2 /Ot /fp:fast /Oy /openmp- /GL
// bug encountered using visual studio 2017 15.9.4 (_MSC_FULL_VER: 191627025)
#include <string_view>
#include <array>
#include <cstdint>
using namespace std::literals;
constexpr auto operator"" _u8(unsigned long long n) noexcept
@marzer
marzer / ice_vs_15.5_15.6_if_constexpr.cpp
Last active December 17, 2017 13:39
Demonstrating an ICE in Visual Studio 15.5 and 15.6 pre1.
//this code causes an internal compiler error in Visual Studio 2017.
//in 15.5 and 15.6 the ICE occurs in 'f:\dd\vctools\compiler\cxxfe\sl\p1\c\parsetree.cpp' on line 1692.
//in the MSVC dailies (19.13.26014.0 used for this test),
//the ICE occurs in 'f:\dd\vctools\compiler\cxxfe\sl\p1\c\parsetree.cpp' on line 1711.
#include <string>
#include <sstream>
#include <iostream>
#include <utility>
template <class CHAR>
@marzer
marzer / ice_vs_15.5_prev2.cpp
Created October 27, 2017 01:42
Demonstration of ICE on VS 15.5 Preview 2
//This code causes an internal compiler error on visual studio 15.5 preview 2's version of MSVC
#include <math.h>
#include <utility>
struct Vector3 final
{
float x, y, z;
};