Skip to content

Instantly share code, notes, and snippets.

@degski
Created May 6, 2019 15:10
Show Gist options
  • Save degski/c18ca8033efd1a946ca609602e9cdbc2 to your computer and use it in GitHub Desktop.
Save degski/c18ca8033efd1a946ca609602e9cdbc2 to your computer and use it in GitHub Desktop.
Clang bug 38102
// MIT License
//
// Copyright (c) 2019 degski
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <cstdlib>
#include <random>
namespace lehmer_detail {
template<typename rtype, typename stype, auto multiplier>
class mcg {
stype state_;
static constexpr auto MCG_MULT = multiplier;
static constexpr unsigned int STYPE_BITS = 8 * sizeof ( stype );
static constexpr unsigned int RTYPE_BITS = 8 * sizeof ( rtype );
public:
using result_type = rtype;
static constexpr result_type min ( ) { return result_type ( 0 ); }
static constexpr result_type max ( ) { return ~result_type ( 0 ); }
mcg ( stype state = stype ( 0x9f57c403d06c42fcUL ) ) : state_ ( state | 1 ) {
// Nothing (else) to do.
}
void advance ( ) { state_ *= MCG_MULT; }
result_type operator( ) ( ) {
advance ( );
return result_type ( state_ >> ( STYPE_BITS - RTYPE_BITS ) );
}
bool operator== ( const mcg & rhs ) { return ( state_ == rhs.state_ ); }
bool operator!= ( const mcg & rhs ) { return !operator== ( rhs ); }
// Not (yet) implemented:
// - arbitrary jumpahead (see PCG code for an implementation)
// - I/O
// - Seeding from a seed_seq.
};
} // namespace lehmer_detail
using mcg128 = lehmer_detail::mcg<uint64_t, __uint128_t, ( __uint128_t ( 5017888479014934897ULL ) << 64 ) + 2747143273072462557ULL>;
using mcg128_fast = lehmer_detail::mcg<uint64_t, __uint128_t, 0xda942042e4dd58b5ULL>;
int main ( ) {
mcg128 gen;
}
/*
1>------ Build started: Project: MSVC-LLVM1, Configuration: Debug x64 ------
1>Assertion failed: getActiveBits() <= 64 && "Too many bits for uint64_t", file C:\src\llvm_package_358402\llvm\include\llvm/ADT/APInt.h, line 1565
1>Stack dump:
1>0. Program arguments: C:\Program Files\LLVM\bin\clang-cl.exe -cc1 -triple x86_64-pc-windows-msvc19.16.0 -emit-obj -mrelax-all -mincremental-linker-compatible -disable-free -main-file-name main.cpp -mrelocation-model pic -pic-level 2 -mthread-model posix -relaxed-aliasing -menable-no-infs -menable-no-nans -menable-unsafe-fp-math -fno-signed-zeros -mreassociate -freciprocal-math -fno-trapping-math -ffp-contract=fast -ffast-math -ffinite-math-only -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu haswell -target-feature +mmx -target-feature +sse -target-feature +sse2 -target-feature +sse3 -target-feature +sse4.1 -target-feature +sse4.2 -target-feature +aes -target-feature +avx -target-feature +avx2 -target-feature +bmi -target-feature +bmi2 -target-feature +popcnt -target-feature +f16c -target-feature +xsaveopt -target-feature +lzcnt -target-feature +fma -target-feature +pclmul -target-feature +xsave -target-feature +rdrnd -target-feature +fxsr -target-feature +adx -mllvm -x86-asm-syntax=intel -D_DEBUG -D_MT -flto-visibility-public-std --dependent-lib=libcmtd --dependent-lib=oldnames -stack-protector 2 -fcxx-exceptions -fexceptions -fexternc-nounwind -fms-volatile -fdefault-calling-conv=cdecl -fdiagnostics-format msvc -gcodeview -debug-info-kind=limited -momit-leaf-frame-pointer -coverage-notes-file Y:\REPOS\MSVC-LLVM1\MSVC-LLVM1\main.gcno -resource-dir C:\Program Files\LLVM\lib\clang\9.0.0 -I y:\vcpkg\installed\x64-windows-static\include -D WIN64 -D _DEBUG -D _CONSOLE -D NOMINMAX -D SFML_STATIC -D _UNICODE -D UNICODE -internal-isystem C:\Program Files\LLVM\lib\clang\9.0.0\include -internal-isystem y:\vc\x64\include -internal-isystem y:\vc\x64 -internal-isystem C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include -internal-isystem C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\atlmfc\include -internal-isystem C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\VS\include -internal-isystem C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt -internal-isystem C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um -internal-isystem C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\shared -internal-isystem C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\winrt -internal-isystem C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\cppwinrt -internal-isystem Include\um -O0 -Wall -Wno-error -Wno-unused-function -Wno-unused-variable -Wno-language-extension-token -Wno-deprecated-declarations -Wno-unknown-pragmas -Wno-ignored-pragmas -Wno-unused-private-field -Wno-unused-command-line-argument -Wno-gnu-anonymous-struct -Wno-nested-anon-types -fdeprecated-macro -fdebug-compilation-dir Y:\REPOS\MSVC-LLVM1\MSVC-LLVM1 -ferror-limit 19 -fmessage-length 0 -fno-use-cxa-atexit -fms-extensions -fms-compatibility -fms-compatibility-version=19.16 -std=c++17 -fobjc-runtime=gcc -fno-caret-diagnostics -fdiagnostics-show-option -fno-show-column -fforce-enable-int128 -std=c++17 -faligned-allocation -pedantic -ffast-math -fcolor-diagnostics -fcoroutines-ts -ffine-grained-bitfield-accesses -ffixed-point -fmodules -fmodules-ts -fsized-deallocation -o Y:\REPOS\MSVC-LLVM1\x64\Debug\main.obj -x c++ main.cpp -faddrsig
1>1. <eof> parser at end of file
1>2. main.cpp:85:5: LLVM IR generation of declaration 'main'
1>3. main.cpp:85:5: Generating code for declaration 'main'
1>0x00007FF6D3362E66 (0x0000000000000016 0x00007FF6D3362E60 0x0000006400000000 0x00007FFDED95A510)
1>0x00007FFDED8DDA2D (0x0000000000000601 0x00007FF600000000 0x000000000000061D 0x00007FF6D5711044), raise() + 0x1DD bytes(s)
1>0x00007FFDED8DE901 (0x00007FFD00000003 0x00007FFD00000003 0x00007FF6D5711044 0x00007FF6D5710DAE), abort() + 0x31 bytes(s)
1>0x00007FFDED8E0261 (0x000000000000061D 0x00007FF6D5711044 0x000001776DBFB580 0x000001776DBF9770), _get_wpgmptr() + 0x18A1 bytes(s)
1>0x00007FFDED8E0591 (0x000000000000007F 0x000000006AB26200 0x0000006433B88D58 0x0000006400000000), _wassert() + 0x71 bytes(s)
1>0x00007FF6D546346A (0x0000000000000000 0x000001776AB83F00 0x0000006400000002 0x0000006433B88C20)
1>0x00007FF6D545CB32 (0x0000006433B88C80 0x0000000000000000 0x0000006433B88AA0 0x0000000800000000)
1>0x00007FF6D545BB9B (0x0000000000000011 0x0000006433B89501 0x000001776BE429D0 0x0000000000000000)
1>0x00007FF6D5458F1D (0x000001776DBFB5A0 0x00007FF600000000 0x000001776DBFB5A0 0x4100135BECF3F4AB)
1>0x00007FF6D54635C2 (0x000001776DBFB580 0x00007FFDED87C7EB 0x000001776DBFB580 0x0000393000000000)
1>0x00007FF6D545F3F6 (0x000001776CA5F5B8 0x0000000000000008 0x00007FF6D665A27E 0x0000006433B89400)
1>0x00007FF6D5453655 (0x000001776AB6F8F0 0x00007FF6D51BF844 0x000001776AB189E0 0x000000000000002D)
1>0x00007FF6D35CB235 (0x0000000000000020 0x0000000000000000 0x0000135BECF3EE9B 0x000001776AB09310)
1>0x00007FF6D35D94E2 (0x000001776AB09310 0x000001776AB17060 0x000001776D8909B8 0x0000135BECF3EC4B)
1>0x00007FF6D35D3519 (0x0000000000000004 0x0000000000000004 0x000001776AADB8A0 0x000001776DBFB470)
1>0x00007FF6D35D2CDF (0x0000006433B899F8 0x00000A4300000001 0x0000135BECF3E3AB 0x0000000000000050)
1>0x00007FF6D35C7382 (0x0000135BECF3E2CB 0x000001776DBFBD00 0x0000000000000000 0x000001776AB6F8F0)
1>0x00007FF6D35CC406 (0x000001776B9EF140 0x0000135BECF3E2EB 0x0000135BECF3E2BB 0x000001776AB6F801)
1>0x00007FF6D35C7382 (0x000001776AB6F8F0 0x000001776BB7C1B0 0x0000006433B89ED8 0x000001776DBFBD38)
1>0x00007FF6D35DE120 (0x0000000C00000057 0x0000017700000000 0x0000135BECF3E7AB 0x0000000000000010)
1>0x00007FF6D35DED8B (0x0000135BECF3E7FB 0x0000000000000000 0x000001776BB7C1B0 0x0000000000000008)
1>0x00007FF6D37EC5F6 (0x0000135BECF3E54B 0x000001776AB6F8F0 0x0000000000000000 0x0000000000000000)
1>0x00007FF6D37E8968 (0x0000000500000057 0x00007FF600000000 0x0000135BECF3E5EB 0x000001776AB6F8F0)
1>0x00007FF6D37E84D1 (0x0000135BECF3E43B 0x00007FF6D6790510 0x000001776D92E200 0x000001776DBFBC40)
1>0x00007FF6D386E34B (0x000001776D92E200 0x000001776DBFBC40 0x0000000000000001 0x0000000000000003)
1>0x00007FF6D3865A8B (0x0000135BECF3E4CB 0x00007FF6D358A65D 0x000001776D92E278 0x00007FF6D35871ED)
1>0x00007FF6D3864E7D (0x0000000000000001 0x000001776DBFBC40 0x0000000000000001 0x00007FF6D570E2F4)
1>0x00007FF6D386EDB5 (0x0000006433B8A360 0x00007FF6D37A2D33 0x0000006433B89E80 0x0000000000000000)
1>0x00007FF6D375125F (0x0000135BECF3D99B 0x000001776D92E278 0x000001776DBFBC40 0x000001776AB1A470)
1>0x00007FF6D3751CB0 (0x000001776DBFBD00 0x000001776DBFBD38 0x000001776DBFBD38 0x00007FF6D35A1855)
1>0x00007FF6D3595A59 (0xFFFFFFFFFFFFFFFF 0x0000000000000000 0xFFFFFFFFFFFFFFFF 0x0000000000000000)
1>0x00007FF6D358DC09 (0x000001776DBFCF90 0x00007FFDED87C7EB 0x0000006433B8BDA0 0x0000000000000000)
1>0x00007FF6D35923D5 (0x0000006433B8BE60 0x0000000200000001 0x0000006400000001 0x0000006400000001)
1>0x00007FF6D3599126 (0x00007FF6D4DDDEE0 0x0000006433B8D628 0x0000135BECF3AE5B 0x000001776ABC0A50)
1>0x00007FF6D57001CF (0x000001776ABC0A40 0x0000000000000000 0x000001776ABC0A40 0x000001776DBFBC40)
1>0x00007FF6D56FDDB7 (0x0000000000000000 0x00007FF6D3AB67FF 0x00007FF6D6373DC6 0x0000000000000004)
1>0x00007FF6D47FA0E3 (0x0000000000000000 0x0000000000000000 0x0000135BECF3AFBB 0x000001776AAAA7A0)
1>0x00007FF6D3AFD330 (0x000001776AB08B50 0x00007FF6D570A023 0x00000000000000C0 0x000001776AB33550)
1>0x00007FF6D3AB9DAF (0x00007FF6D570E901 0x0000000000000000 0x0000000000000000 0x00000000000000B6)
1>0x00007FF6D3B5E4B5 (0x0000000000000000 0x000001776AB066F0 0x0000000000001801 0x0000000000000000)
1>0x00007FF6D1737284 (0x00000000000006A6 0x0000000000000000 0x000000001A00001A 0x00000000000006B0)
1>0x00007FF6D1734715 (0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000)
1>0x00007FF6D570A248 (0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000)
1>0x00007FFDEEC87974 (0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000), BaseThreadInitThunk() + 0x14 bytes(s)
1>0x00007FFDF175A271 (0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000), RtlUserThreadStart() + 0x21 bytes(s)
1>clang-cl : error : clang frontend command failed due to signal (use -v to see invocation)
1>clang version 9.0.0 (trunk)
1>Target: x86_64-pc-windows-msvc
1>Thread model: posix
1>InstalledDir: C:\Program Files\LLVM\bin
1>clang-cl: note: diagnostic msg: PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
1>clang-cl: note: diagnostic msg:
1>********************
1>
1>PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
1>Preprocessed source(s) and associated run script(s) are located at:
1>clang-cl: note: diagnostic msg: C:\Users\jimme\AppData\Local\Temp\main-dbe73c.cpp
1>clang-cl: note: diagnostic msg: C:\Users\jimme\AppData\Local\Temp\main-dbe73c.sh
1>clang-cl: note: diagnostic msg:
1>
1>********************
1>Done building project "MSVC-LLVM1.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment