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

For maximal portability, you wouldn't want to shift a 12 bit field by more than 3 bits. Because you know that is narrower than int, but int can be as narrow as 16 bits, which includes a sign bit.

If you assume that int is 32 bits, you can left shift an 12 bit field by 19 bits without hitting the sign bit.


I would say, GCC's behavior shows commitment to the standard. It's exactly he same logic as the promotion of char/signed char/unsigned char, or int and unsigned int.

That is to say, if we work this example with bitfields that are 8 bits wide, like

  uint32_t uf2 : 8;

  bf.uf2 = 255;
and use a shift of 24:

  u2 = bf.uf2 << 24;
the behavior observed on GCC will not change if we edit the declaration of the member to unsigned char:

  unsigned char uf2;
I.e. an unsigned bitfield that is 8 bits wide is basically like unsigned char and promotes that way. From that the reasoning follows for other widths.

You're supposed to know that bitfields undergo promotion as they were small integers, even if they are declared to be something like unsigned int.

Therefore, convert the values before operating on them:

    u1 = ((uint64_t) bf.uf1) << 20;
    u2 = ((uint64_t) bf.uf2) << 20;

I just can agree with any interpretation of the article's code that believes programmers should desire silent sign extension when everything about the expression and data types involved is explicitly written to avoid signedness. At the end of the day, programming languages should naturally express intent and not rely on memorization of surprise. Here, I believe that Microsoft correctly employed principle of least surprise, and that ultimately the spec is broken and because of the amount of code in existence just can't be fixed.

I completely agree that C's promotion behavior of unsigned types narrower than int going to int is wonky to a certain extent. However, introducing nonconforming exceptions to that behavior for bit fields doesn't help things. It just breaks correctly written code intended to be portable.

If they serve me slop with only a few good bits, I'm doing saguribashi.

> SSH, on the other hand, has no equivalent of a Host header.

SSH cannot multiplex to different servers on the same host:port. But you can use multiple ports and forwarding.

You could give each machine a port number instead of a host name:

   ssh-proxy:10001
   ssh-proxy:10002
When you ssh to "ssh-proxy:10002" ("ssh -p 10002 ssh-proxy" wth your OpenSSH client that doesn't take host:port, sigh), it forwards that to wherever the 10002 machine currently is.

It would be interesting to know why they rejected the port number solution, but the only hit for "port" in the article is in the middle of the word "important" in the sentence:

But uniform, predictable domain name behavior is important to us, so we took the time to build this for exe.dev.

You can have uniform, predictable domain + port behavior. Then you don't need a smart proxy which routes connections based on identities like public keys. Just manipulation of standard port forwarding (e.g. iptables).


> The large battery in an EV makes it easier to feed powerful computers, and it allows things like over-the-air updates to happen when the car is parked and “off.”

I don't want anything of the sort as a consumer, so auto makers who don't "get" it either are fine by me. Nay, heroes.


Also, lol, "the large battery in an EV makes it easier to feed powerful computers". Do they not think an internal combustion engine can power a few ARM chips? What could the total power consumption of all the computer equipment in a car be, like 30-50 watts? 200 horsepower is 147 kW.

Even the point about running computers when the car is off seems wildly uninformed: a 12 V starter battery in an ICE car is about 70 Ah. That’s 840 Wh. So you can run a 5 W computer (that does nothing but periodically wake up to look for and download updates and such) for 168 hours. (Of course, any competent implementation will not let electronics run the battery flat, but it still seems like way more than enough)


> but there should be a trusted 3rd party service that does that

No, there shouldn't be any such thing; everyone pushing for any shape of this should just bugger off.


> When I was around 10, in 1975, I built a giant computer out of a cardboard box.

In around 1976, when I was five, I followed a smaller design: mine fit entirely inside an egg carton, with the tops painted various colors representing buttons. I had a roll of punched paper tape as a souvenir from my aunt, who worked in accounting for textile company. I fed that tape into the egg carton as input.

And so here we are ...


They had no privacy laws in the Paleolithic era, so this sort of doxxing is totally legit. Neanderthals cannot simply rely on the flesh being gone and bone being replaced by stone to conceal their faces.


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

Search: