Skip to content

Instantly share code, notes, and snippets.

Davide Italiano dcci

Block or report user

Report or block dcci

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@dcci
dcci / gist:27a191c991052a1b71cb
Created Oct 17, 2015
Go home clang, you're drunk.
View gist:27a191c991052a1b71cb
% cat template.cpp
template<class T>
class X {
T f(T x) { return x; }
T foo(void);
};
template<class T>
T X::foo(void)
View gist:8910a17770e46ecce3dc
[1984/2575] Building CXX object tools/clang/lib/CodeGen/CMakeFiles/clangCodeGen.dir/CGExprScalar.cpp.o
FAILED: /usr/bin/CC -DCLANG_ENABLE_ARCMT -DCLANG_ENABLE_OBJC_REWRITER -DCLANG_ENABLE_STATIC_ANALYZER -DGTEST_HAS_RTTI=0 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor -std=c++11 -fcolor-diagnostics -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -Wno-nested-anon-types -Itools/clang/lib/CodeGen -I../tools/clang/lib/CodeGen -I../tools/clang/include -Itools/clang/include -Iinclude -I../include -I/usr/local/include -fno-exceptions -fno-rtti -MMD -MT tools/clang/lib/CodeGen/CMakeFiles/clangCodeGen.dir/CGExprScalar.cpp.o -MF tools/clang/lib/CodeGen/CMakeFiles/clangCodeGen.dir/CGExprScalar.cpp.o.d -o tools/clang/lib/CodeGen/CMakeFiles/clangCodeGen.dir/CGExprScalar.
View gist:efaea9678788d74769a4
#include <assert.h>
#include <link.h>
#include <dlfcn.h>
#include <stdio.h>
#include <pthread.h>
static int
callback(struct dl_phdr_info *info, size_t size, void *data)
{
void *handle;
View gist:e69cad69179e23069267f4f986be0975
[davide@localhost bin]$ g++ blah.cpp -o blah
blah.cpp: In function ‘int main()’:
blah.cpp:10:9: error: ‘union’ tag used in naming ‘struct G<int>’ [-fpermissive]
union G<int> foo;
^
blah.cpp:4:7: note: ‘struct G<int>’ was previously declared here
class G {
^
[davide@localhost bin]$ cat blah.cpp
#include <stdio.h>
View gist:c737c11cc58c0c13bffac3dab30c6002
*** Dumping AST Record Layout
0 | class llvm::DILocalVariable
0 | class llvm::DIVariable (base)
0 | class llvm::DINode (base)
0 | class llvm::MDNode (base)
0 | class llvm::Metadata (base)
0 | const unsigned char SubclassID
1:0-1 | unsigned int Storage
2 | unsigned short SubclassData16
4 | unsigned int SubclassData32
@dcci
dcci / gist:f83538d46dbcde9457bc663a2218c97e
Created Jun 23, 2016
Replacing malloc() on Windows.
View gist:f83538d46dbcde9457bc663a2218c97e
#include <limits.h>
#include <malloc.h>
#include <new.h>
#include <windows.h>
#include <stddef.h>
#include <stdio.h>
namespace {
const size_t kWindowsPageSize = 4096;
const size_t kMaxWindowsAllocation = INT_MAX - kWindowsPageSize;
@dcci
dcci / floating.c
Last active Jul 13, 2016
Floating point is fun
View floating.c
#include <math.h>
#include <stdio.h>
int main(void) {
// pow(x, 0.5) -> sqrt(x)
printf("%f %f\n", pow(-0.0, 0.5), sqrt(-0.0));
return (0);
}
View gist:5f674b93f8bfeae393e01bc35a9b9228
#!/bin/sh
/home/davide/work/llvm-monorepo/build/bin/opt @$1 /home/davide/work/llvm-monorepo/build/bin/unopt.ll -o - | /home/davide/work/llvm-monorepo/build/bin/lli | grep ^1
ret_sane=$?
/home/davide/work/llvm-monorepo/build/bin/opt-broken @$1 /home/davide/work/llvm-monorepo/build/bin/unopt.ll -o - | /home/davide/work/llvm-monorepo/build/bin/lli | grep ^-1
ret_broken=$?
[[ $ret_sane == 0 && $ret_broken == 0 ]] && exit 0
exit 1
View gist:95da518b5216c7e187d49b0dcf88d880
[davide@localhost build]$ ninja check-llvm
[573/2081] Building CXX object lib/Transfor...ar/CMakeFiles/LLVMScalarOpts.dir/SCCP.cpp.o
FAILED: /usr/lib64/ccache/c++ -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Ilib/Transforms/Scalar -I../lib/Tran
sforms/Scalar -Iinclude -I../include -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long
-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment -Werror=date-time -std=c++11 -g -fno-exceptions -fno-rtti -MMD -MT lib/Transforms/Scalar/CMakeFiles/LLVMScal
arOpts.dir/SCCP.cpp.o -MF lib/Transforms/Scalar/CMakeFiles/LLVMScalarOpts.dir/SCCP.cpp.o.d -o lib/Transforms/Scalar/CMakeFiles/LLVMScalarOpts.dir/SCCP.cpp.o -c ../lib/Transforms/Sca
lar/SCCP.cpp
../lib/Transforms/Scalar/SCCP.cpp: In member function ‘void {anonymous}::SCCPSolver::markOverdefined({anonymous}::LatticeVal&, llvm::Value*)’:
../lib/
@dcci
dcci / btree.rs
Last active Mar 1, 2017
btree interface
View btree.rs
use std::marker::PhantomData;
/// A B-tree data structure which nodes are allocated from a pool.
pub struct BTree<K, V> {
index : u32,
unused1: PhantomData<K>,
unused2: PhantomData<V>
}
// A Node reference is a direct index to an element of the pool.
You can’t perform that action at this time.