WTF Bites


  • Considered Harmful

    @anotherusername If I'm writing a constant that is produced most concisely via overflow, I don't want to pre-compute that with a separate program. Compiler's job.

    Edit: If I'm okay with overflow it's also because I'm only interested in the LSB, so I would indeed rather stay in a numeric type (for which, say, instructions exist) for rather than cast up and down.



  • @Gribnit said in WTF Bites:

    If I'm writing a constant that is produced most concisely via overflow

    You're not.

    I don't want to pre-compute that with a separate program.

    Too bad.

    Compiler's job.

    No.

    Here, I'll tell you what. The error message can tell you "Use constant xxxx instead." Now the compiler's doing it for you, but you're not doing bad constant math in your code anymore. Good enough?


  • Considered Harmful

    @anotherusername So, you are aware that constants exist and can be initialized via expressions?



  • @Gribnit An expression made up of multiple parts is never more concise than the single constant value which results from the evaluation of that expression. :pendant:


  • Considered Harmful

    @anotherusername I don't give a fuck about conciseness here re byte count. I give a fuck about what is actually comprehensible. If I'm computing a constant it's because it will make more sense that way. And if the compiler sees me computing a constant, it better compute it then, at compile time.



  • @Gribnit You're the one who brought up conciseness as a reason.

    I'm having trouble seeing any situation where you'd need the compiler to evaluate an expression and then throw away part of the result, and like I said, if you do need that you can just explicitly declare the result to be a sized integer type so that the portion that doesn't fit is explicitly thrown away.



  • @Gribnit Can you give an example where the constant is best calculated via overflow?


  • Considered Harmful

    @anotherusername unsigned, you mean? where would I get arbitrary precision by default in a strongly typed language?

    If you had limited your original suggestion to "invokes undefined behavior" I'd be fine with this response, but you wanted: hard error for overflow, underflow, and div/0,
    not: hard error on invokes undefined behavior.

    I could see underflow and div/0 being hard error but overflow is just expected in some circumstances, compile and run time. Overflow is not a bug.

    Although I feel that I'm wasting time by providing an example: for a good time, try computing a decent hash without overflow.


  • Considered Harmful

    @jmp If it's a hash, seems the most obvious answer.


  • Considered Harmful

    @anotherusername said in WTF Bites:

    The error message can tell you "Use constant xxxx instead."

    No. Fuck no, are you just trolling? That's the kind of shit that gets 10,000,000 man hours of bitching about in usage.



  • @Gribnit said in WTF Bites:

    @jmp If it's a hash, seems the most obvious answer.

    That wouldn't normally be a compile-time constant though, would it? I mean I guess you could write a constexpr hash function, but that's not really the case being considered here; the thing @anotherusername has a problem with is this sort of behaviour:

    const unsigned int some_constant = 0xffff << 24; // undefined behaviour if sizeof(int) <= 4 etc.
    

    I think there's room for a compiler to error out on that example but tolerate overflow in constexpr uint32_t hash_func(std::string_view sv).

    (Or maybe it only errors if the integer is signed. 1u << 32 is perfectly defined after all)



  • @jmp said in WTF Bites:

    1u << 32 is perfectly defined after all

    I don't know about C++, but in C it is undefined if int is 32-bit-wide (or less).
    (I just took a look at the K&R to check.)



  • @jmp said in WTF Bites:

    undefined behaviour

    Not undefined in Go.



  • Sure, but there's nothing special about Go here. It's probably not undefined either in Java or C#, or any properly-designed language after C/C++.



  • @Zerosquare said in WTF Bites:

    @jmp said in WTF Bites:

    1u << 32 is perfectly defined after all

    I don't know about C++, but in C it is undefined if int is 32-bit-wide (or less).
    (I just took a look at the K&R to check.)

    According to these guys,
    C Standard, 6.2.5, paragraph 9:
    "A computation involving unsigned operands can never overflow, because a result that cannot be represented by the resulting unsigned integer type is reduced modulo the number that is one greater than the largest value that can be represented by the resulting type."

    Which matches my general understanding of the standard - unsigned overflow/underflow is perfectly defined, signed overflow/underflow is undefined (because it would reveal how signed integers are implemented).

    Unless there's something I'm missing about how unsigned literals work?

    @ben_lubar said in WTF Bites:

    @jmp said in WTF Bites:

    undefined behaviour

    Not undefined in Go.

    Are they planning on fixing that bug any time soon? :P

    EDIT: this Stack Overflow answer has several more standards quotes on unsigned overflow being defined; but nothing specific about compile-time literals.



  • The copy of the 2nd edition K&R I have is a French translation, but it says this about the bit-shifting operators:

    The result is undefined if the right-hand operand is negative, or is larger or equal to the number of bits of the left-hand operand type.

    Looks like they tightened that for unsigned integers in C99 and above?



  • @Zerosquare said in WTF Bites:

    The copy of the 2nd edition K&R I have is a French translation, but it says this about the bit-shifting operators:

    The result is undefined if the right-hand operand is negative, or is larger or equal to the number of bits of the left-hand operand type.

    Looks like they tightened that for unsigned integers in C99 and above?

    Aha! That's what I'm missing; overflow on unsigned is defined, but bitshifts with rhs >= number of bits in expression result is undefined as you've correctly identified. Whoops. cppreference notes this in it's page on arithmetic operators; scroll down to "shift operators" to find:

    In any case, the behavior is undefined if rhs is negative or is greater or equal the number of bits in the promoted lhs.

    2u << 31 is defined though.



  • @Gribnit said in WTF Bites:

    where would I get arbitrary precision by default in a strongly typed language?

    You wouldn't, but if the language has a large enough type to do computations without overflowing, you should be able to assume that it'll do so. Or, you should be able to assume that all integer constants are int64, even if they would fit in a smaller size. When actually assigning them, an error should occur if the integer doesn't fit into the data type it's being stored as, which you can bypass by explicitly declaring it to be that type, in which case a warning will be emitted saying that loss of data has occurred.

    for a good time, try computing a decent hash without overflow.

    You wouldn't be doing that in a constant expression.

    @Gribnit said in WTF Bites:

    No. Fuck no, are you just trolling? That's the kind of shit that gets 10,000,000 man hours of bitching about in usage.

    That wasn't the whole error message, silly. It was just an example of some information that could be included to make the error message more helpful by telling you the constant number that you wanted the compiler to calculate -- "xxxx" was supposed to represent that number.

    @jmp said in WTF Bites:

    the thing @anotherusername has a problem with is this sort of behaviour:

    const unsigned int some_constant = 0xffff << 24; // undefined behaviour if sizeof(int) <= 4 etc.
    

    Basically yes, although I think any RHS expression would be simplified as much as possible by the compiler, and a constant expression is a RHS that simplifies to a single constant value -- not just one that's assigned to a declared const.

    Another example (using a signed type this time) would be

    int some_constant = INT_MIN / -1; // overflow
    

  • Considered Harmful

    [post deleted]


  • Considered Harmful

    @anotherusername said in WTF Bites:

    "xxxx" was supposed to represent that number.

    See original response but louder. If the compiler calculated it, let it compile it, the fuck in.

    Edit: Thanks for clarifying that your position was exactly as it appeared to be. 10,000,000 man hours is based on the estimate of time spent bitching (up to and including creating new languages) about "missing semicolon".

    You wouldn't be doing that in a constant expression.

    Are you magic? Or, are you just telling me what all my programs may ever do, as opposed to will ever do? This distinction matters (but not a lot).


  • Java Dev

    I guess I am TR:wtf: for visiting Oracle, but...

    0_1533208533641_oracle-cookie-wtf.PNG



  • @jmp said in WTF Bites:

    Are they planning on fixing that bug any time soon?

    Which bug? The arbitrary precision constant folding is part of the spec.



  • @Gribnit said in WTF Bites:

    Overflow is notmay or may not be a bug.

    It is, in fact, an rather common source of bugs IME. Which is why you absolutely, positively should tell your co-workers "I'm sure overflow is not a bug in this particular case", and the compiler should error out if you don't.

    What the means are to tell the compiler this may be up to debate, but not the fact that it is necessary.



  • @jmp said in WTF Bites:

    2u << 31 is may be implementation defined or undefined though

    ...as it is up to the implementation to decide how many bits to use for an unsigned int. So the result could be any of 0, 4294967296 or <nasal demons>, depending on your platform.


    Filed Under: C integers are a pain in the ass


  • Considered Harmful

    As long as I can tell the compiler "do what I said cause I said it" I won't care. Integers (fixed-size 2s-complement integers) are ring math, though, quite fundamentally. They won't stop being that. This being a warning is fine. I hear it's already a warning.



  • @anotherusername said in WTF Bites:

    Here, I'll tell you what. The error message can tell you "Use constant xxxx instead." Now the compiler's doing it for you, but you're not doing bad constant math in your code anymore. Good enough?

    Let's make it even better: the IDE offers to replace or add the constant directly where you wrote the operation.


  • Java Dev

    @Gribnit said in WTF Bites:

    As long as I can tell the compiler "do what I said cause I said it" I won't care. Integers (fixed-size 2s-complement integers) are ring math, though, quite fundamentally. They won't stop being that. This being a warning is fine. I hear it's already a warning.

    Not according to the Standard. Unsigned integers can overflow and wrap around; UINT_MAX + 1 will evaluate to zero. On a decimal hardware architecture this will not be at a power of two.

    Signed integer overflow is undefined behaviour. Undefined behaviour does not mean "If the code flow gets there the compiler/CPU can do whatever". Undefined behaviour means the compiler can do whatever at any time. In practice, the compiler can (and an optimising compiler will) assume any code path containing undefined behaviour is unreachable. Writing if( condition ) { INT_MAX + 1 } can be interpreted by the compiler to mean 'condition will always be false at this point'.



  • @Gribnit said in WTF Bites:

    This being a warning is fine. I hear it's already a warning.

    Warnings are useless. Either you set the "treat warnings as errors" option, or in no time you will have so many warnings in the code that you'll ignore all of them anyway.

    IMHO the only useful way to handle such things is to 1) make them errors, and 2) offer a clean way to explicitly say "I know what I'm doing, shut up".


  • Considered Harmful

    @PleegWat said in WTF Bites:

    decimal hardware architecture

    Chrissakes, BCD is even in play here?



  • @anonymous234 said in WTF Bites:

    Apparently the McDonald's queueing system does NOT give more priority to your order if you just order one, pre-made item.

    No, it doesn't. It's a FIFO system for the most part, unless all you're buying are drinks and the order taker can just hand you the cups right away.

    So an Oreo shake to go can take 9 minutes. So much for fast food.

    A milkshake wshouldn't be pre-made. The mix tends to not hold up well to conditions other than the exact temperature in the machine. The freezer is too cold, freezing it solid; the fridge is too warm, melting it down.



  • @Gribnit said in WTF Bites:

    dirty laundry bomb

    My family used to call a baby's dirty diaper a "bomb". I used to wonder what would have happened if one of my little brothers said he "had a bomb" while in a "secure" public place like an airport. It tends to get pretty expensive to fly a large family around, so we rarely ever flew as a family. In fact, the only time I can remember all of us flying together when that sort of situation could have occurred was a Make-A-Wish trip to Disney World (and all the other amusement parks around Orlando, FL [and seriously, check out and support Give Kids the World Village]), so we didn't actually have to pay for the tickets.



  • @ben_lubar said in WTF Bites:

    @bb36e said in WTF Bites:

    regardless of network device is on

    so if you go on WiFi and are viewing a video over HTTPS, it caps your video download "speed" to 480p?

    Makes sense to me, though it skips a few steps in the description:
    The speed is capped so that 480p video is the highest quality that will be able to stream continuously fast enough to watch smoothly as it streams.



  • @Polygeekery said in WTF Bites:

    @anotherusername said in WTF Bites:

    @Polygeekery said in WTF Bites:

    Those fuckers are going to compensate me for the food at the very least.

    LOL. Good luck with that.

    Want to wager some money on that? ;)

    I'd be willing to lay some money that says you get something satisfactory to you. :D



  • Glad I'm not on Comcast - someone posted to our nextdoor group (this was a thread about suspicious cars stopped on the street)

    If you or your neighbors have Comcast for internet service then you are a wifi "hot spot". Anyone stopping in front of your home can use your wifi as long as they are a Comcast internet customer. There is nothing you can do about it.


  • Considered Harmful

    @dcon

    @dcon said in WTF Bites:

    There is nothing you can do about it.

    Eh, you could stick their hardware in a Faraday cage and route only cable through it, to an AP you control.



  • @dcon said in WTF Bites:

    There is nothing you can do about it.

    Remove the antenna 🤷🏻♂


  • Considered Harmful

    @TimeBandit No external antenna on their crapboxes iirc



  • @Gribnit then the Faraday cage is the best option



  • @ixvedeusi said in WTF Bites:

    Warnings are useless. Either you set the "treat warnings as errors" option, or in no time you will have so many warnings in the code that you'll ignore all of them anyway.

    We do this when compiling C/C++. We still have thousands of warnings from compiling Verilog, assorted scripts, and run-time. Does anybody care? 😢

    Edit: Heck, we have one build that produces a bunch of errors. "Yeah, those are expected. You can ignore them."



  • @dcon That's only true if you're dumb enough to use Comcast's cable modem instead of getting your own.



  • @Polygeekery said in WTF Bites:

    @Scarlet_Manuka said in WTF Bites:

    You know, you shouldn't believe those sorts of emails.

    Someone remind me this week and I will tell the story. It's a pretty good one.

    Story reminder? (If it's already posted, a reply to this reminder request would be helpful. :) )


  • Considered Harmful

    @blakeyrat Yeah... I bought a modem a long while back, come to think of it.

    I still see Comcast WAP networks on signal analyzer though. Probably the neighbors. Maybe I should get a pineapple.



  • @Gribnit You can still USE other people's Comcast wifi points (if you remember your login), but you don't provide one yourself.

    In all fairness, in theory Comcast's "public" wifi won't count against your bandwidth limits and supposedly it'll get throttled so it won't affect your max speed. At least that's what they claim. I always bring my own modem, so I can't test to confirm.


  • Notification Spam Recipient

    @blakeyrat my ISP throttles after the first 20mb so I probably wouldn't notice regardless.



  • @Tsaukpaetra said in WTF Bites:

    my ISP throttles after the first 20mb

    IOW, your connection is always throttled 🤷🏻♂



  • For your :wtf: pleasure, the AWS console's group by alphabetically:

    0_1533232718065_aws_wtf.PNG

    Need Redshift? Is it under 'R'? No, it's 'A' because it's Amazon Redshift.

    The mixing of names and acronyms is pretty annoying too. Everywhere in the documentation calls Simple Notification Service SNS, same with Simple Queue Service. Either stick with the formal names, or use the acronym.


  • Considered Harmful

    @theBread I think "sniz quiz" is perfectly acceptable for SNS/SQS.



  • @theBread did they consolidate their interfaces or does it still look like a different intern worked on each one?



  • @homoBalkanus said in WTF Bites:

    @theBread did they consolidate their interfaces or does it still look like a different intern worked on each one?

    For the most party they all look similar, but there are a ton of external tools that have different UIs, like QuickSight.



  • @theBread

    0_1533234291248_dd297c5b-926c-40de-972f-8b6e6512cc24-image.png

    They even cover the Wife Acceptance Factor, and offer a shield if she doesn't 😲


Log in to reply