Skip to content

Instantly share code, notes, and snippets.

View 1vanK's full-sized avatar
🇷🇺

1vanK

🇷🇺
  • Russian Federation
View GitHub Profile
@1vanK
1vanK / WhatIsStrictAliasingAndWhyDoWeCare.md
Created October 15, 2022 08:02 — forked from shafik/WhatIsStrictAliasingAndWhyDoWeCare.md
What is Strict Aliasing and Why do we Care?

What is the Strict Aliasing Rule and Why do we care?

(OR Type Punning, Undefined Behavior and Alignment, Oh My!)

What is strict aliasing? First we will describe what is aliasing and then we can learn what being strict about it means.

In C and C++ aliasing has to do with what expression types we are allowed to access stored values through. In both C and C++ the standard specifies which expression types are allowed to alias which types. The compiler and optimizer are allowed to assume we follow the aliasing rules strictly, hence the term strict aliasing rule. If we attempt to access a value using a type not allowed it is classified as undefined behavior(UB). Once we have undefined behavior all bets are off, the results of our program are no longer reliable.

Unfortunately with strict aliasing violations, we will often obtain the results we expect, leaving the possibility the a future version of a compiler with a new optimization will break code we th

@1vanK
1vanK / UrhoExporter.cs
Created February 9, 2020 18:08 — forked from gleblebedev/UrhoExporter.cs
Unity to Urho3D scene convertor
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml;
using UnityEditor;
using UnityEngine;
@1vanK
1vanK / opengl3_hello.c
Created April 3, 2018 16:12 — forked from koute/opengl3_hello.c
Minimal SDL2 + OpenGL3 example.
/*
Minimal SDL2 + OpenGL3 example.
Author: https://github.com/koute
This file is in the public domain; you can do whatever you want with it.
In case the concept of public domain doesn't exist in your jurisdiction
you can also use this code under the terms of Creative Commons CC0 license,
either version 1.0 or (at your option) any later version; for details see:
http://creativecommons.org/publicdomain/zero/1.0/
//
// Copyright (c) 2008-2017 the Urho3D project.
//
// 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:
//
Scene@ scene_;
Node@ cameraNode;
float yaw = 0.0f; // Camera yaw angle
float pitch = 0.0f; // Camera pitch angle
void Start()
{
scene_ = Scene();
scene_.LoadXML(cache.GetFile("Scenes/TestSoftParticles.xml"));
#include "Urho3DAll.h"
#include "Game.h"
#include "SmoothFocus.h"
URHO3D_DEFINE_APPLICATION_MAIN(Game)
Game::Game(Context* context) :
Application(context),
@1vanK
1vanK / Game.cpp
Created November 5, 2015 08:48
HoverBegin HoverEnd bug when resolution is changed
#include "Urho3DAll.h"
#include "Game.h"
URHO3D_DEFINE_APPLICATION_MAIN(Game)
Game::Game(Context* context) : Application(context)
{
}