Why on earth do they want me to pay CHF 216 for the C standard https://www.iso.org/standard/74528.html
Is there a free version of this? And isn't this weird that a lot of OSS is written in C but the standard is behind a big fat paywall?
I just have question about unions...
=> More informations about this toot | More toots from brauner@mastodon.social
Basically my questions comes down to whether in an anoymous union like:
struct foo { union { struct { struct bar b[5]; /* 60 bytes */ u32 nr_entries; }; struct { void *p; void *q; }; }; };
I can use nr_entries to index p/q and b.
=> More informations about this toot | More toots from brauner@mastodon.social
IOW, if I did:
struct foo meh = {
.nr_entries = 1234,
.p = some_array;
.q = some_other_array;
};
can I rely on that no being undefined behavior. I think C11 guarantees this type punning.
=> More informations about this toot | More toots from brauner@mastodon.social
I think I might've annoyed @arnd already with that question before?
=> More informations about this toot | More toots from brauner@mastodon.social
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2310.pdf
"99) If the member used to read the contents of a union object is not the same as the member last used to store a value in the
object, the appropriate part of the object representation of the value is reinterpreted as an object representation in the new
type as described in 6.2.6 (a process sometimes called "type punning"). This might be a trap representation."
=> More informations about this toot | More toots from brauner@mastodon.social
@brauner https://www.iso-9899.info/wiki/The_Standard has links to the voting drafts.
=> More informations about this toot | More toots from vathpela@better.boston
@brauner IME the best bet is to search for the standard number + "draft", possibly also with filetype:pdf.
And yes, it's weird and annoying to be behind a paywall.
=> More informations about this toot | More toots from AndresFreundTec@mastodon.social
@AndresFreundTec This feels a lot like academia where you have to send someone a mail to get access to their doctoral thesis to avoid throwing money into the great wide academic publisher void.
=> More informations about this toot | More toots from brauner@mastodon.social
@brauner the drafts should be on open-std.org.
=> More informations about this toot | More toots from Valentin@mastodon.social
@brauner The drafts are freely available, for example https://port70.net/~nsz/c/c23/n3220.pdf or https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3301.pdf for C23. These are close enough to the final documents to be useful in most cases. https://stackoverflow.com/q/81656/4500798 has extensive lists.
=> More informations about this toot | More toots from skitt@mastodon.social
@brauner I don't remember the question or the answer ;-)
As to your earlier question, I think the draft C standards tend to be freely avaiable, only the final version with the correct cover letter is paywalled. There is a good chance you can find the solution in https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf
=> More informations about this toot | More toots from arnd@society.oftrolls.com
@arnd Ah, sorry. I was wondering about https://mastodon.social/@brauner/113108101553403428
=> More informations about this toot | More toots from brauner@mastodon.social
@brauner
waaait... the C standard says union members do type punning?
how the heck can they possibly guarantee that when type-based anti-aliasing is used?
like, this clang example shows why that can't really work:
https://godbolt.org/z/c38K61Th5
struct bar { long c; };
long blah(struct foo *f, struct bar *b) {
f->a = 1;
long l = b->c;
f->a = 2;
return l;
}
union u {
struct foo foo;
struct bar bar;
};
long bar_union(union u *u) {
return blah(&u->foo, &u->bar);
}
output:
mov rax, qword ptr [rdi]
mov dword ptr [rdi], 2
ret
How does the standard handle this - is there some separate rule in the standard that forbids passing pointers to two different union members to the same function or what?
(sidenote: The Linux kernel disables strict aliasing rules in the compiler, so strict aliasing concerns don't really apply in the kernel.)
=> More informations about this toot | More toots from jann@infosec.exchange
@jann @brauner C, especially with unions, is YOLO
=> More informations about this toot | More toots from jduck@infosec.exchange
@jann @brauner last I checked, the standard didn't handle this at all, and it was subject to debates because it means that strict aliasing is void, but compiler people don't like that.
=> More informations about this toot | More toots from siguza@infosec.space
@brauner Linux has been depending on this kind of thing for a while now after adding struct_group(). So, from a practical perspective, "yes", but yeah, good to check the spec. :)
=> More informations about this toot | More toots from kees@fosstodon.org
Can someone explain how the ISO specification paywall fits into the general economy of open standards maintenance? Does it allow the process to not 'sell out' in some harmful way? #ISO #FOSS @brauner
=> More informations about this toot | More toots from Delib@floss.social This content has been proxied by September (ba2dc).Proxy Information
text/gemini