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 / vs_2022_tuple_ref_bug.cpp
Last active August 22, 2023 12:48
vs_2022_tuple_ref_bug
// demonstration of a bug in VS2022 / MSVC 19.38.32919
//
// repro steps:
// 1. make a C++17 or later project in VS2022
// 2. add the single-header library "soagen.hpp" to it from here:
// https://raw.githubusercontent.com/marzer/soagen/ace22525eeff90d0ff9228b78d0045db87c24099/src/soagen/hpp/single/soagen.hpp
// 3. add this code file to it
// 4. compile + run
// 5. observe that line 53 below (ends with "#### BUG") evaluates to the wrong result
// 6. inspect the values in the debugger will show the references are corrupted
// repro of two lambda-related bugs in MSVC 1933.31517 (VS 2022 17.3.0 Pre2)
//
// required flags: /std:c++17 or /std:c++20 or /std:c++latest (all fail)
//
// previously worked in whatever the MSVC version was in VS 2022 17.3.0 Pre1
#include <type_traits>
#define REPRO_INTERNAL_COMPILER_ERROR 1
#define REPRO_INCORRECT_TRAIT_VALUE 1
@marzer
marzer / vs_2019_template_specialization_bug.h
Created September 19, 2021 18:44
MSVC Template partial specialization bug repro
template <typename T>
struct type_and_nttps
{
static constexpr bool value = false;
};
template <template <typename> typename T, typename U>
struct type_and_nttps<T<U>>
{
@marzer
marzer / vs_2019_16.10.0_pre2_consteval_bug.cpp
Last active April 21, 2021 12:53
MSVC 16.10.0 Preview 2 consteval bug repro
// Minimal repro for producing an erroneous C7595 error in Visual Studio 2019 16.10.0 Preview 2 (CL 19.29.30031.0).
//
// Steps to reproduce:
// 1. Compile with /std:c++latest in Visual Studio 2019 16.10.0 Preview 2 (CL 19.29.30031.0)
// 2. Observe C7595 at the line marked below
// 3. Comment out the 'REPRO' line and rebuild
// 4. Observe that plain ol' constexpr works OK
using size_t = decltype(sizeof(void*));
// Repro of intellisense parse errors for VS2019 16.8.5
//
// Steps:
// 1. Add this file to a VC++ project in VS2019 16.8.5
// 2. Set C++ language level to /std:c++17 or higher
// 3. Right-click the code window > Rescan > Rescan File
// 4. Right-click the code window > Rescan > Display Browsing Database Errors
// 5. Observe that the parser generates 'VCTP001' warnings at the code regions marked below
//
@marzer
marzer / stl.natvis
Created January 14, 2021 06:59
Microsoft STL Natvis file - VS 2019 16.8.4
<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
<!-- VC 2015 -->
<Type Name="std::_Compressed_pair&lt;*,*,1&gt;">
<DisplayString>{*($T1 *)this}</DisplayString>
<Expand>
<ExpandedItem>*($T1 *)this</ExpandedItem>
</Expand>
</Type>
@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
@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 / 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
//_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