• 0 Posts
  • 21 Comments
Joined 2 years ago
cake
Cake day: June 13th, 2023

help-circle
  • Been there, found undefined behavior where there should not be any. Imagine a function that takes a bool param with the following code, but neither branch gets executed:

    if (b)
       doStuffForTrue();
    if (!b)
       doStuffForFalse();
    

    In a function that is passed an uninitialized bool parameter, in gcc compiler, both branches can get executed even when b is const. Reason: uninitialized bool in gcc can have values of a random integer, and while if(b) {} else ({} is guaranteed to execute only one branch, bool evaluations of a bool value take a “shortcut” that only has defined behavior with an initialized bool.

    Same code with an uninitialized integer works as expected, btw.




  • I was probably on a different continent ^^ Also, the biggest problem explaining math is not making it understandable, but having a motivated learner. Most students that have a bad teacher in school, or are somehow not motivated in school to begin with, will also not be motivated to focus on easier explanations. Technically a basic interest in math should be fostered / encouraged in kids from an early age, and at the latest in elementary school. If that does not work out, many students will have a hard time with it.

    You are welcome.