Hacker Newsnew | past | comments | ask | show | jobs | submit | munchler's commentslogin

It looks like you submitted a random page within the website instead of pointing to the home page.

The code in question is:

    if (sprtemp[frame].rotate == false)
Note that this is explicitly comparing two values, which is very different from checking whether a single value is true. Surely you wouldn't expect -1 == 0 to evaluate to true.

> Surely you wouldn't expect -1 == 0 to evaluate to true.

I wouldn't, no - but that's exactly what's happening in the test case.

Likewise, I wouldn't expect -1 == 1 to evaluate to true, but here we are.

The strict semantics of the new bool type may very well be "correct", and the reversed-test logic used by the compiler is certainly understandable and defensible - but given the long-established practice with integer types - i.e "if(some_var) {...}" and "if(!some_var) {...}" - that non-zero is "true" and zero is "false", it's a shame that the new type is inconsistent with that.


>Surely you wouldn't expect -1 == 0 to evaluate to true.

No, but that's not what happened. What happened was that 255 == 0 was true. That's a bug.


> memset (sprtemp,-1, sizeof(sprtemp));

Yikes. I think this article undersells the point somewhat. This line of code undermines the type system by spraying -1's into an array of structs, so the only surprise to me is that it took this long to break.


`spriteframe_t` is defined as

  typedef struct
  {
    // If false use 0 for any position.
    // Note: as eight entries are available,
    //  we might as well insert the same name eight times.
    boolean rotate;

    // Lump to use for view angles 0-7.
    short lump[8];

    // Flip bit (1 = flip) to use for view angles 0-7.
    byte flip[8];
    
  } spriteframe_t;
which is okay to splat with all-ones as long as `boolean` is either a typedef for a fundamental type(*) or an enum – because C enums are just ints in a trenchcoat and have no forbidden bit patterns! The C99 `bool`/`_Bool` is, AFAICS, the first type in C that has fewer values than possible bit patterns.

So yeah, on C99 and C++ this always had UB and could've broken at any time – though I presume compiler devs were not particularly eager to make it ill-behaved just because. But in pre-C99 it's entirely fine, and `rotate == true || rotate == false` could easily be false without UB.

---

(*) other than `char` for which setting the MSB is… not UB but also not the best idea in general.


And, indeed, if you look at the author's writeup, you see exactly that the generated code satisifes `(rotate == true || rotate == false) == false`, since rotate is checked explicitly against 0 and 1. The essence of the difference is:

> When boolean is an enum, the compiler does exactly what I expected – the == false condition checks if the value is equal to 0, and the == true condition checks if the value is equal to 1.

> However, when boolean is actually _Bool, the == false check is transformed into != 1, and the == true check is transformed into != 0 – which makes perfect sense in the realm of boolean logic. But it also means that for a value of 255, hilarity ensures: since 255 is neither 0 nor 1, both conditions pass!

So a value of 255 also makes both checks fail for the enum, but because of the ordering of the code, it was expected to evaluate as != false.

Had the check: ``` if (sprtemp[frame].rotate == false) ```

been written as: ``` if (sprtemp[frame].rotate != true) ```

then it would work for the `bool` type, but not the `enum` type, at least in C23 mode. Assumedly the C++ mode (effectively) treated the boolean as an enum, or possibly as `false == 0`, `true != 0`.


Maybe changing the type of the variable to int was the better solution?

C99 does not use bool unless you explicitly include stdbool.h, which won't be in any pre-C99 code. By default, you just get _Bool.

C has no particularly strong type system, and it works on typical platforms with all types up to the introduction of _Bool. And maybe float/double, but I think it gives a NaN.

> Anxiety is the second leading cause of disability and mortality worldwide.

I think this comes from WHO, but isn't consistent with other information from WHO, so it's pretty debatable.

I believe the source is this[0], which says "Mental health conditions such as anxiety and depression are highly prevalent in all countries and communities, affecting people of all ages and income levels. They represent the second biggest reason for long-term disability, contributing to loss of healthy life."

However, elsewhere on their site[1], WHO lists the top 3 global causes of death and disability in 2021 as heart disease, COVID-19, and stroke.

[0] https://www.who.int/news/item/02-09-2025-over-a-billion-peop...

[1] https://www.who.int/data/gho/data/themes/theme-details/GHO/m...


No, its very reliable after consideration for how anxiety works from a physiological perspective and what does to a person's health and how modifies their decisions and behaviors. When all these factors are taken into account anxiety alone may account for most other more directly measured mortality conditions.

The other side of that coin is that anxiety is also most prominently the result of social conditioning as opposed to diagnosed illness. This results in anti-anxiety medications that are vastly over-prescribed for individuals that receive less than ideal benefits.


> every month there's a 14-day period with no solar power

So it's dark 50% of the time on the moon... just like here on Earth.


... and completely not like a sun-synchronous Earth orbit which is dark 0% of the time.

I would suggest the US is slightly better. At least we don’t have an unenforceable law that offers the illusion of privacy protections.

There’s an implicit assumption in this snark that the only purpose of a law is to create legal consequences (a subclass of error that’s very common on this forum, some type of “literalism”).

This is IMO a bit shortsighted: laws impact culture, laws represent ideals worth striving for, and in a democracy, laws help define the type of society in which the people would like to live.

A law’s utility is not limited to its ability to be enforced. In fact, in a democracy, when a law is not enforced, it is a strong signal that the will of the people is not being carried out by those charged with enforcement. See: the current USDOJ.


"Will of the people" aside, the law is indeed a teacher. It sets a norm and an expectation even when not enforced.

Except when “not enforced” becomes the norm and the expectation.

That's not the norm or an expectation in question, though. People get away with breaking laws all the time. It's very common. But the fact that something is illegal by itself exerts a psychological effect that sets an expectation and modulates the Overton window of the perceived norm. Such laws also enable enforcement. It is untrue that unless a law is perfectly enforced, it is useless or bad.

But you would agree that, despite the DEA not raiding dispensaries in legal states, the fact that marijuana is still a Schedule 1 drug still has some meaning? It’s almost retained as a pretense to keep certain prisoners behind bars despite the rest of society kind of moving on from the Reagan-era propaganda. So even though non-enforcement is the norm and expectation, the law still has an impact on society.

The purposes and effects of laws are complicated. This thread started because someone blithely claimed that the US is in a better situation because they have no laws concerning privacy because GPDR is difficult to enforce. I’m pushing back against that (as a US citizen) because it’s a damaging and myopic viewpoint that may or may not be based in American exceptionalism or techbro cynicism or something else entirely.


how is having NO law better? I'd say 12 out of 20, is better than zero.

When enforcement is this shoddy, it’s easy to create corruption through selective enforcement.

“We don’t have the resources to go after everyone, so we must prioritize” - but it turns out there’s a bias to the selection process…

I believe that justice is only true when we are all treated equally under the law.


I think you mean 8 out of 20. Fewer than half.

In my house, the bedrooms are two flights of stairs above the dryer in the basement. Good luck wheeling.

This seemed like a bad idea to me from the beginning. Giving personal biometric details to a monster corporation is a nonstarter for both techies and normies.


I agree in theory, but yet I have an iPhone, and Apple is managing my biometrics. I do not have Clear, or TSA preCheck, etc. but still my biometrics are in the US database.

So, in practice, I am not sure if that is truly a non-starter for "normies" and even some "techies". I already gave up on my face biometrics living in US.


Your biometrics are in the secure enclave of your specific phone. Apple doesn't have them in a database.


They do have ways to access to them, which is the same thing in my book.

https://www.bleepingcomputer.com/forums/t/809154/apple-silen...


I don't think this shows that at all?

How else can you patch an exploit if you don't try it first? The first step in reverse engineering malware is to try the exploit in a controlled environment.

Exactly, this is why it failed. Suddenly in every Whole Foods is an Amazon device saying "give me your hand print!" Uh, no.


I call it plausible deniability.

My fingerprints and palmprints have gone through so many biometric studies through multiple colleges and I know they’ve done experiments with copying and making false biometrics from some of their study samples.

What’s not to love?


Because we’re interested in AGI (emphasis on general) and LLM’s are the closest thing to AGI that we have right now.


Wouldn't have expected something like this to end on a cliffhanger, but... what happened next?


As far as I can google, him publishing this is the last thing we know.

https://en.wikipedia.org/wiki/Calvin_Tomkins


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: