Skip to content

Instantly share code, notes, and snippets.

@zwimer
Created November 12, 2024 14:56
Show Gist options
  • Select an option

  • Save zwimer/9b95d756b23ef0171cdd4c8d3edefeb2 to your computer and use it in GitHub Desktop.

Select an option

Save zwimer/9b95d756b23ef0171cdd4c8d3edefeb2 to your computer and use it in GitHub Desktop.

Revisions

  1. zwimer created this gist Nov 12, 2024.
    18 changes: 18 additions & 0 deletions bools.cpp
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    #include <iostream>

    void f(bool b) {
    if (b == true) { std::cout << "true\n"; }
    if (b == false) { std::cout << "false\n"; }
    }

    int main() {
    char c = 2;
    bool * b = (bool*) &c;
    f(*b);
    }

    /*
    Without optimizations might print:
    true
    false
    */