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

help-circle
  • Don’t blame this on gcc or the library/function author - it is 100% user (i.e. programmer) error. Uninitialised memory of any type is undefined behaviour in the C and C++ abstract machine. That means optimising compilers can assume it does not exist.

    I absolutely do blame this on the C++ standard being not specific enough, specifically for the way in how I learned about this: When writing a trivial function, you would never expect that - for a bool parameter - an “if (b)” branch can be executed as well as an “if (!b)” branch.

    So basically, this mechanic sabotages input data validation in functions that test whether plausible parameters were provided. The problem is that a function you write that is bug-free and “perfect code” - despite input data validation - can exhibit undefined behavior due to an uninitialized bool type parameter. Something that can not happen with other uninitialized trivial (numeric) data types (int, float). Simply due to the way boolean checks are translated to x86 assembly:

    Here’s an example: https://godbolt.org/z/T3f9csohd

    Note the assembly lines 176-182: The only difference for the “if (!b)” check is that the lowest bit of the boolean is flipped with an xor - which assumes about the implementation that a boolean can never hold values other than 0 or 1. Which I - as a naive user - also assumed until this happened. Correction: I assumed that negating a bool would result in the inverse boolean value.

    So the problem boils down to: The value range of any given (built-in) numerical data type fully encloses the value range that an uninitialized variable of that type can have. This is not necessarily true for boolean: In g++, the value range is [0;1] and the range of an uninitialized bool is [0;255].

    Accordingly, I would expect the C++ standard to fix this by stating that an uninitialized bool must have a value for which only one of two conditions evluates to true: b or !b, but not both.


  • 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.












  • Like, at an old company the UI had really bad mouse tunnels (mouse over menus and sub menus that close if you mouse out). Terrible interface. But someone in management liked it and no one would approve changing it. Easy to look at it and say we’re all morons, but most of the stupid there was from leadership.

    If more people had a backbone and spoke out / refused to implement shitty stuff, this wouldn’t happen. Also, many design choices are entirely on the web developer. Thus morons. I’m not gonna change my opinion until websites become usable again, you’re wasting your time on me.


  • well obviously you shouldn’t use a Taiwan flag to represent Traditional Chinese if you’re selling in China, dumbass, you shouldn’t need special training to know that… […] at least a few of the 8 million Ukrainians who speak Russian probably aren’t keen on identifying themselves in their profile with a Russian flag either”

    fair enough, that is a good point.

    Again, and I feel like I’m repeating myself here, my point isn’t that you’re incorrect, it’s that getting on your high horse about it and calling people dumb

    No, I wasn’t calling people dumb, I was calling “most web developers” morons, and I stand by that. Most web developers are morons. And the language topic at hand is just one of many symptoms of that. Way more annoying than that is that almost all websites have been fubared with stupid frameworks and interactive sites transmitting each keypress and reloading parts of the page while you are trying to use them / whatever was in your focus before. Interactive websites can be done right, but most of the time they are not, and it’s the fault of stupid marketing people and crappy web developers / designers who do NOT refuse to implement shitty marketing ideas.


  • The only thing I know about i18n is that it is an annoying shitload of language installer packages for both firefox and libreoffice ^^ That said, however, how you need training for a localization package to provide a language menu(!) - not the translations, mind you - in English, is beyond me. I can’t follow the point you seem to be trying to make. There’s no reason to not hardcode (in English) a language selection menu, and then display the list of available site languages (and these should be a country flag with the name of language next to it in what may be the language itself)