3 ms·
The only embedded sizes I've ever seen are flex, 0, 1, and 14 (sockaddr's). It's trivial enough to exclude all of them.
by dataflow 2y ago
The only embedded sizes I've ever seen are flex, 0, 1, and 14 (sockaddr's). It's trivial enough to exclude all of them.
- AshamedCaptain 2y agoNo, I have seen many people use an arbitrary value to indicate "this is the amount it makes most sense to allocate this structure with", e.g. when you allocate it on the stack. If you need more than that you allocate it with a malloc wrapper or the like, which returns one of arbitrary long size. What I have not seen is this happening in the middle of the struct, for obvious reasons; it's always the last element in the struct.
- dataflow 2y ago> No, I have seen many people use an arbitrary value Have you seen that in something that's ABI-critical, though? i.e. whose code simply cannot be changed due to backward compatibility, like is the case with sockaddr? Because otherwise I'd consider it a non-issue.
- AshamedCaptain 2y agoEverything is an ABI issue. Dunno what the point or alternative is here.
- dataflow 2y agoNo? Not every struct is exposed to clients who can't change their code.
- AshamedCaptain 2y agoI still do not see the point. No one wants to change their code. No one wants to break their ABI. But the discussion is moot since I do not see what ABI break is being proposed here. My only guess is that the proposal you're envisioning is to forbid this pattern, which breaks a lot of perfectly working code, not just 'ABI'.
- garaetjjte 2y ago>flex, 0, 1 And each one can behave differently: https://lwn.net/Articles/908817/ https://lwn.net/Articles/908817/