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

That stuff gets rediscovered all the time, the latest example probably being golang

China is very much repeating the history of Japan, and while we can argue how democratic Japan was in the second half of the XX century it definitely wasn't totalitarian.

Its part Japanese and Koreas model and part British Empire Mercantilism.

But not having fixed size integers (or integers tied to the size of a pointer) was. Both can be useful

What is the size of a pointer though?

On Intel 286 we had a 16-bit machine word and 24-bit addresses. A pointer wasn't just two machine words concatenated - the upper 8 bits were stored somewhere else - a segment register.

On modern machines we don't (usually) need to consider this because we have a single linear virtual address space, though the size is architecture dependant - usually above 40 bits and below 64. Most common size is 48-bits, but also up to 57-bits with 5 level paging enabled.

Either way we round up to 64-bits to store the pointer as one integer. C optionally provides types `intptr_t` and `uintptr_t`, which are integers large enough to hold the value of a pointer. Converting a pointer to `intptr_t` and back to the pointer type results in a pointer that compares equal to the original.

However, there is no guarantee that a pointer converted to `intptr_t` and back to a pointer can be dereferenced! It works most of the time because of our linear address space and non-use of segmentation, but segmentation can still be used - the FS and GS segment registers are still available on x86_64 and are commonly used for thread local storage. If you take a `thread_local T*`, convert it to `intptr_t`, and then convert it back to a `thread_local T*` on another thread and attempt to dereference it, then despite the pointers comparing equal, they dereference to different virtual addresses.

Integers tied to the size of a pointer would have been misguided. Pointers are not integers! (They just happen to use an integer in their representation).

Another one, `size_t` is supposed to represent the maximum size of any object. However, that's also not well-defined. The maximum object size on the Intel 256 would have been 16-bits, because that is all you can fit in a single segment.

On a modern machine, a `size_t` should really be 48-bits (4LP) or 57-bits (5LP), because we can't have an object larger than our maximum virtual address size - but `size_t` is typically 64-bits.


`thread_local` is a storage class, there is no `thread_local T*` in the same way there is no `static T*`

Yeah, but my point is that two pointers can compare equal but point to different addresses, thus it's not necessarily a safe operation to dereference a pointer cast from `intptr_r`.

I don’t know what you mean, if you take the address of a thread local variable you get a regular pointer which is just as safe to dereference as any other pointer, cast through intprt_t or not?

It's safe to dereference in the same thread.

A `thread_local`'s actual virtual address is not merely what the pointer contains - it's an offset from some other virtual address stored in the FS or GS register (on x86-64), which is swapped when you change thread. Casting the pointer to `intptr_t` does not retain the segment base address - only the offset. The pointer is not the absolute address.

If you dereference in another thread, it's the same offset, but from a different base address.

There may be other things besides segment registers on other architectures that also make it unsafe. The C standard makes no guarantee that you can safely dereference a pointer cast from `intptr_t`.


I’m sorry but this is just incorrect. When you take the address of a thread local variable you have to lookup its real address using something like __tls_get_addr or by reading its offset via fs/gs but once it’s in a pointer it’s just a regular absolute address and is fine to dereference on any thread. There is no separate type for a pointer to a thread local variable.

That's an implementation choice. The standard makes no such guarantees.

> An integer may be converted to any pointer type. Except as previously specified, the result is implementation-defined, may not be correctly aligned, may not point to an entity of the referenced type, and can produce an indeterminate representation when stored into an object

The compiler may specify otherwise. GCC specifies that the pointer cast to integer back to pointer must point to the original object, else the behavior is undefined.


> What is the size of a pointer though?

a MISERABLE_LITTLE_PILE_OF_BITS


It turns out that you don't want integers the same size as a pointer because somebody might squirrel away capability bits in your pointer type (see CHERI) and you definitely do not want integers with capability bits.

Rust originally says that its types usize and isize are the same size as pointers, but this was ret-conned in later Rust to say actually they're the same size as addresses for this reason.


At the time its was probably very hard to know what the fixed sizes should be.

PL/I among other systems languages predating C, had the ability to explicitly define bit sizes for its types.

> Our power on the world stage will decrease, our infrastructure will start to be neglected due to lack of investment, quality will diminish in most areas…

I believe you've chosen the wrong tense there


Haha, fair point.

The EU is no longer the largest economic bloc in the world, but that happened due to Brexit.


That would make it the only company in the world not doing that

> Europeans don't get that choice

We absolutely, 100% do. Not everywhere, just like it isn't universally true in the US, but it definitely is a choice that many in Europe have. We just aren't chained to a car even in this case, public transport is still great even if you don't live in the city center.


It might be great where you are but it definitely isn't where I am in Norway, nor was it in quite a few of the rural places I visited in the UK this summer.

Do you have a city or region in mind?

That makes it even worse for european automakers, if they cannot compete even with a heavily tariffed BYD

We don't have materials, we don't have energy.

Not sure how are we supposed to thrive in a world where cars are very simple and our know-how is borderline useless.

Imho cars are a dead race-to-the-bottom business, that was true in ICE world, that will be even more true in the electrified/autonomous driving one.


> I don't see other nations reproducing the French institutions

Gaullism and strong governments are not in fashion these days. The main thing that made Messmer plan work was Messmer himself, a strong leader with the power to tell everyone to stfu and do it.


> Humans should focus on finding simple solutions that lead to a 10X improvement

How many humans can you name who really did that? Like, in the whole history of our species


This world has 8.3 thousand thousand thousand humans in 2026. With such mindnumbly vast population, and our feeble primate brains (see Dunbar's number) limiting us to relate to about 150 people, I don't think it's fair to ask for names, intimate or not.

Nevertheless it's certain that there has to be people alive who saw a complex problem and simplified it 10x, even if the solution never got out of their local sphere. Solutions that you and me would implement with automation and sensors, people in developing countries would find a way with less technology or resources. Even our current systems seem needlessly complex and overengineered compared to when hardware was a limitation.

If you want to think about needless complexity being everywhere, take for example the simplicity of the Internet, made when hardware was limited, against modern monstrosities like Bluetooth, now that we can just throw more hardware at problems.


> there has to be people alive who saw a complex problem and simplified it 10x

Absolutely. Let's be generous and say that there are a thousand of them alive today, what about everyone else? Are their lives meaningless now?

> the simplicity of the Internet

The Internet is TCP/IP and TCP/IP is a lot of things but hardly "simple"


99.9% of humanity don’t derive meaning from their work, sad but true. They don’t care if their life has meaning, if their work is actually valuable etc.

HN just selects for the latter who care. Yes it’s probably much harder for those who care to have a meaningful life in the presence of LLM’s unfortunately.


Didn't Americans send all their freedom to Iran?

Yes, and now they're running out.

You mean the state of Iran?

So now Iran with their freedom ?

yes, diesel is 1 cent per liter. For $50 can drive the whole month non stop.

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

Search: