News for hackers. Stuff that matters.
Re:Everything I wish I knew when learning C by bombcar on Monday November 28, 2022 @06:42PM (#33781535)
That would be a nice little "gcc addition" to the C standard, honestly.

To bad they spend most their time doing whatever it is they do.

Re:Everything I wish I knew when learning C by maxdamantus on Monday November 28, 2022 @07:32PM (#33782001)
Earlier versions of gcc actually used to support this in a very restricted context in C90 (or maybe gnu89) mode:

  struct foo { int a[10]; };
  struct foo f(void);
  int b[10];
  b = f().a;
In C90, you can't actually do anything with `f().a` because the conversion from array to pointer only happened to lvalues (`f().a` is not an lvalue), and assignment is not defined for array variables (though gcc allowed it). The meaning is changed in C90 so that non-lvalue arrays are also converted to pointers. gcc used to take this distinction into account, so the above program would compile in C90 mode but not in C99 mode. New versions of gcc seem to forbid array assignment in all cases.

I think this quirk also means that it's technically possible to pass actual arrays to variadic functions in C90, since there was nothing to forbid the passing (it worked in gcc at least, though in strict C90, you wouldn't be able to use the non-lvalue array). In C99 and above, a pointer will be passed instead.

Re:Everything I wish I knew when learning C by pjmlp on Tuesday November 29, 2022 @02:46AM (#33784742)
I have long been convinced that WG14 has no real interest in improving C's security beyond what a Macro Assembler already offers out of the box.

Even the few "security" attempts that they have made, still require separate pointer and length arguments, thus voiding any kind of "security" that the functions might try to achieve.

However even a Macro Assembler is safer than modern C compilers, as they don't remove your code when one steps into a UB mine.

Re:Everything I wish I knew when learning C by Gibbon1 on Tuesday November 29, 2022 @06:21AM (#33786166)
One of the members of WG14 posted here a few days ago that they only use C89.
Re:Everything I wish I knew when learning C by ErikCorry on Tuesday November 29, 2022 @06:52AM (#33786400)
Mind blown.