Skip to content

TorchedArchive/luckcalc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

luckcalc

Feeling unlucky? Want to find out if you're having good or bad luck today? For the low price of free and a potential segfault luckcalc can provide!

Usage

Simple and easy:

git clone https://github.com/TorchedSammy/luckcalc
cd luckcalc
make

And run with luckcalc.exe (Or ./luckcalc on *nix)

But..

undefined behaviour

What??

This program defines 2 uninitialized variables (bad_luck and good_luck) and reads them to figure out your luck. (I personally haven't gotten bad luck yet lmaoooooo)
Uninitialized variables may not always be what you expect in a local scope. They can be (say for us with an int type) 69, 6467 or whatever.

As this stackoverflow answer says (edited for C++):

Static variables (file scope and function static) are initialized to zero:

int x; // zero
int y = 0; // also zero

void main() {
    static int x; // also zero
    std::cout << x;
}

Non-static variables (local variables) are indeterminate. Reading them prior to assigning a value results in undefined behavior.

void main() {
    int x;
    std::cout << x; // the compiler is free to crash here
}

About

check your luck with a lucky change at a segfault

Resources

License

Stars

Watchers

Forks