Live data from Hacker News

Google broke a conditional statement that verifies passwords on Chrome OS

arstechnica.com

231–240 of 276 posts

Re: Google broke a conditional statement that verifies passwords on Chrome OS

#231
post #102

Earlier quoted context omitted.

"Not as weak as Java" is not a very interesting benchmark, as Java also has a poor type system. C++'s type system is pitiable relative to those of Rust, Haskell, OCaml, and SML. Moreover, in addition to being less expressive than them, C++'s type system is also weak , in formal sense, by allowing many implicit type conversions - which is one of the issues that I was complaining about. The fact that it "has to be in p…

The fact implicit conversions exist doesn't really weaken the type system, the two are different concepts. If you define an overload or a type specialization on both the compiler will call the right version without any ambiguity. You can even define your own implicit conversions itself, and sometimes they have their uses, like when you need to wrap values in proxies but you still don't want the user to actually have…

It is nothing to be amazed, other than we are finally able to enjoy such type systems in mainstream languages.

PL/I and Algol 68 were equally powerfull, or if you research into was being done in Xerox PARC workstations.

If anything, we are 30 years too late for where we could have been if it wasn't for UNIX winning the worstation market.

Re: Google broke a conditional statement that verifies passwords on Chrome OS

#232

Earlier quoted context omitted.

Java has a poor type system, but not as poor as that of C++.

This is uttely false. I desume you haven't used C++ in the last 10 years, or at least you didn't delve deep enough into it to really understand how powerful (while bonkers) the C++ type system is. C++ has a much, MUCH more stronger type system with true generics, value types, const-correctness, compile time reflection and dispatching, ... In Java, everything is a reference, except when it's not (which is a design mis…

I just wish there would be a -fsafe compiler flag instead of having to deal with all the sanitizers and debug mode flags, but it is what it is.

Re: Google broke a conditional statement that verifies passwords on Chrome OS

#234

Earlier quoted context omitted.

Java has a poor type system, but not as poor as that of C++.

This is uttely false. I desume you haven't used C++ in the last 10 years, or at least you didn't delve deep enough into it to really understand how powerful (while bonkers) the C++ type system is. C++ has a much, MUCH more stronger type system with true generics, value types, const-correctness, compile time reflection and dispatching, ... In Java, everything is a reference, except when it's not (which is a design mis…

All versions of C++ inherit type system from C and keep it for backward compatibility. Indeed you can opt into a stronger dialect with right compiler flags, but this is used as widely as Prolog, because the rest of ecosystem uses an incompatible dialect and will fight against you. C++20 is a substitute of C++17, not of other languages.

Re: Google broke a conditional statement that verifies passwords on Chrome OS

#235

Earlier quoted context omitted.

While it is true that you can use `and` in C++11, that's a bit of an understatement: these keywords have in fact been present since the very first ISO C++ standard C++98!

Note however that MSVC does not support these by default. You need to #include before their use, or you need to pass the `/permissive-` compiler option.

You should be using /permissive- anyway unless you are dealing with a legacy codebase that breaks with that.

Re: Google broke a conditional statement that verifies passwords on Chrome OS

#236

Earlier quoted context omitted.

Yeah, I know what UB is, and that's why I'm saying that this is not UB. Have you even read what I wrote?

I recommend stepping back for a moment and asking yourself: Why is it that you, the person who believe they "know what UB is" and is sure "this is not UB" did not understand what's going on here, while the other people reading who explained why it's UB have understood exactly what's going on ? Doesn't it seem most likely that you in fact do not understand Undefined Behaviour and didn't understand what's going on ?

I don't think you understand UB, because clearly, this is not UB.

But I congratulate you. You have enough knowledge to engage in Internet discussions involving fancy names without understanding underlying concepts.

Hint: 1) Read my original post. 2) Contemplate whether the compiler is removing anything in this instance.

Re: Google broke a conditional statement that verifies passwords on Chrome OS

#237

Earlier quoted context omitted.

Which of "Rust, Haskell (core Haskell), OCaml, and SML" is able to parametrize types on values, à la template ?

Much more usefully, in C++ you can also parametrize over templates, which I think you still can't in rust. You can't parametrize over namespaces (at least not directly) which is an annoying and arbitrary restriction.

> You can't parametrize over namespaces (at least not directly) which is an annoying and arbitrary restriction.

It's not a restriction, namespaces are neither types nor values so they would need specific support. Given that you can (ab)use classes with static members as namespaces which are also a type it's simply that nobody cared enough to add support for templating over real namespaces.

Re: Google broke a conditional statement that verifies passwords on Chrome OS

#238

Earlier quoted context omitted.

This is uttely false. I desume you haven't used C++ in the last 10 years, or at least you didn't delve deep enough into it to really understand how powerful (while bonkers) the C++ type system is. C++ has a much, MUCH more stronger type system with true generics, value types, const-correctness, compile time reflection and dispatching, ... In Java, everything is a reference, except when it's not (which is a design mis…

All versions of C++ inherit type system from C and keep it for backward compatibility. Indeed you can opt into a stronger dialect with right compiler flags, but this is used as widely as Prolog, because the rest of ecosystem uses an incompatible dialect and will fight against you. C++20 is a substitute of C++17, not of other languages.

The desire of maintaining compatibility with C at all cost is both the main selling point of C++ and the source of almost all of its madness. C was full of weird quirks (null terminated strings, enums that decayed to int, char* that could represent arbitrary data, weird syntax inherited from B, nonsensical arrays, ...) but its simplicity has always kinda kept everything down to a tameable level of chaos.

C++ took this quirky base and pushed it (abused it?) in ways that go way beyond what can be considered "sane"; see for instance the bajillion ways operator new() can be redefined, the fact there are at least 10 ways to initialize something, or the fact that features can be _discovered_ and not designed (like CRTP). Still, this wealth of features together with the unwavering (and arguably masochistic) Herculean efforts of the ISO C++ committee to modernize the language make it, by far, one of the most flexible languages around. Every single time I use C++ I discover a new amazing way to do something that had never crossed my mind; call me crazy, but I think this makes programming fun, a detail that is often (wrongly) neglected.

Re: Google broke a conditional statement that verifies passwords on Chrome OS

#239
post #232

Earlier quoted context omitted.

This is uttely false. I desume you haven't used C++ in the last 10 years, or at least you didn't delve deep enough into it to really understand how powerful (while bonkers) the C++ type system is. C++ has a much, MUCH more stronger type system with true generics, value types, const-correctness, compile time reflection and dispatching, ... In Java, everything is a reference, except when it's not (which is a design mis…

I just wish there would be a -fsafe compiler flag instead of having to deal with all the sanitizers and debug mode flags, but it is what it is.

[deleted]

Re: Google broke a conditional statement that verifies passwords on Chrome OS

#240
post #223

Earlier quoted context omitted.

I would imagine has_value is checking to see if a pointer is NULL, and -> is dereferencing that same pointer. When the optimizer sees the two together it realizes the former is useless.

by this logic the compiler would optimize any short-circuiting because it KNOWS the programmer WOULD NEVER deference an invalid pointer

no, & is not short-circuiting
Post reply on HN