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 / 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;
};
@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.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
// godbolt: https://godbolt.org/z/AfIXAD
#include <iostream>
#define MSVC_BUG 1
struct A
{
static constexpr int flag = 1;
};
struct B
//godbolt: https://godbolt.org/z/6Ffp3J
#include <cstdint>
#include <utility>
using namespace std;
template <typename T, size_t N>
class Test
{
private:
@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)
//_MSC_VER: 1923
//_MSC_FULL_VER: 192328107
//Toolset: v142
//Visual studio: 2019 16.3.10
//compiler flags: /std:c++latest /permissive-
#include <string_view>
[[deprecated]]
constexpr std::string_view Test(const char* str, size_t len) noexcept
@marzer
marzer / vs_2019_intellisense_failures.h
Created December 1, 2019 06:41
Header file that causes VS2019 intellisense to fall in a heap.
#pragma once
//--------------------------------------------------------------------
// CONFIGURATION
//--------------------------------------------------------------------
#ifdef TOML_CONFIG_HEADER
#include TOML_CONFIG_HEADER
#endif
@marzer
marzer / rangify_unicode_categories.py
Last active August 20, 2020 12:54
Python script for enumerating and grouping Unicode character categories in ABNF notation.
#!/usr/bin/env python3
# dependencies:
# pip install --upgrade requests
import os.path
import sys
import re
import requests
import traceback
@marzer
marzer / std-fwd.h
Last active October 17, 2020 08:36
Example of forward-declaring std types
// example of forward-declaring std types.
// *** don't use this! it's for exposition only! ***
#pragma once
#ifdef __has_include
#define STDFWD_HAS_INCLUDE(header) __has_include(header)
#else
#define STDFWD_HAS_INCLUDE(header) 0
#endif