Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
uecker
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
18 ms
·
481.
▲
by
uecker
8mo ago
I don't think so. As a contributor to GCC, I also wished it hadn't.
482.
▲
by
uecker
8mo ago
We will likely decide in March that it will became an ISO TS. Given the simplicity of the feature and its popularity, I would assume that it will become part of the standard eventually.
483.
▲
by
uecker
8mo ago
I do not see how defer would have helped in this case.
484.
▲
by
uecker
8mo ago
The advantage is that it automatically adds the cleanup code to all exit paths, so you can not forget it for some. Whether this is really that helpful is unclear to me. When we looked at defer originally for C, Robert Seacord hat a list of
485.
▲
by
uecker
8mo ago
It is not clear to me that defer helps here. The issue is management of state (the return value) not control flow.
486.
▲
by
uecker
8mo ago
It is not yet a technical specification, just a draft for one, but this will hopefully change this year, and the defer patch has not been merged into GCC yet. So I guess it will become part of C at some point if experience with it is good,
487.
▲
by
uecker
8mo ago
IMHO, it is in the best interest of your students to teach them standard C first.
488.
▲
by
uecker
8mo ago
Clang has this and upcoming GCC will also have this: https://godbolt.org/z/KETrPEnT1
489.
▲
by
uecker
8mo ago
You can use pointer types by using a typedef first, but I agree this not nice (I hope we will fix this in future C). But then, I think this is a minor inconvenience for having an otherwise working span type in C.
490.
▲
by
uecker
8mo ago
Only statement expressions, but one can also implement this without them.
491.
▲
by
uecker
8mo ago
Or just do it in C. #define span(T) struct span_##T { size_t len; T *data; } #define span_access(T, x, i) (*({ \ span(T) *_v = (x); \ auto _i = (i); \ if
492.
▲
by
uecker
8mo ago
In my experience it is worse with clang that even more aggressively uses UB than GCC to optimize (and Chris Lattner in his famous blog post very much justified this line of thinking), and I have seen similar things with MSCV. I do not know
493.
▲
by
uecker
8mo ago
It follows from mathematics and logic that "larger than 40%" could be 100%, but it does not follow that this is likely or reasonable to assume.
494.
▲
by
uecker
8mo ago
In theory. But most C programs do not rely on UB. What is the basis for your claim?
495.
▲
by
uecker
8mo ago
I felt the same. There are too few contributors for GCC. At some point I started to fix the bugs that I had filed myself. Still, it is important that the user make themselves heard.
496.
▲
by
uecker
8mo ago
I know, but this still leaves 60% of programs without such UB which is far from "it is practically impossible find a program without UB". Also this this was a study from 2013 and many of those bugs found were fixed. Also GCC got U
497.
▲
by
uecker
8mo ago
This is only relevant for specific types of UB, and even there it is not entirely clear. One of the main challenges is ABI compatibility and separate compilation. Both are not necessarily part of the "design of C". If you are will
498.
▲
by
uecker
8mo ago
I agree. I am not terribly convinced by C++ or Zig's comptime. You should be able to do this at run-time, and then just be able to make it a constant.
499.
▲
by
uecker
8mo ago
C23 did not increase a lot. The core language spec is also very small. Extensions are also often relatively simple, but most importantly, one does not have to use them. ABI is usually not per OS but per architecture.
500.
▲
by
uecker
8mo ago
I am not sure what statement you are responding to. I am certainly not arguing that. I disagree with your claim that "it is practically impossible find a program without UB".
501.
▲
by
uecker
8mo ago
Yes, this is the funny thing. People do not want to spend time using a stricter language as already supported by C compilers using compiler flags because "it is waste of time" while others argue that we need to switch to much str
502.
▲
by
uecker
8mo ago
I think this is not really true. Or rather, it depends on the UB you are talking about. There is UB which is simply UB because it is out-of-scope for the C standard, and there is UB such as signed integer overflow that can cause issues. I
503.
▲
by
uecker
8mo ago
Also what I like about C is that is has mature tooling, very portable with multiple implementations, and that is is very stable. I would not use a language for any serious project hat does not offer all this. Honestly, I do not think that
504.
▲
by
uecker
8mo ago
Where there is UB in the standard it means that a C compiler is free to define the behavior. So of course, somebody could write a C implementation which does this. See also Fil-C for a perfectly memory safe version of C. So the first sente
505.
▲
by
uecker
8mo ago
Rust is not super appealing to me as C user: too complex, slow compilation, etc.
506.
▲
by
uecker
8mo ago
And please provide feedback to WG14. Also please give feedback and file bugs for GCC / clang. There are users of C in the committee and we need your support. Also keeping C implementable for small teams is something that is at risk.
507.
▲
by
uecker
8mo ago
Well, I consider it abuse of header files to put an implementation in there. And comparing including a c-file to IOCCC seems very exaggerated. My experience with dependencies in Debian-derived distributions is actually very good, far less p
508.
▲
by
uecker
8mo ago
People certainly sometimes create a horrible mess. I just do not see that this is a good reason to dumb everything down. With a proper .c/.h split there are many advantages, and in the worst case you could still design it in a way tha
509.
▲
by
uecker
9mo ago
It is not a benefit if you do not get warnings about unused functions. With any proper library, you would also not get warnings for functions that are part of the API that are not used, but you would get warnings about non-exported function
510.
▲
by
uecker
9mo ago
They are certainly bad vendor toolchain, but I want to push back against the idea that this is a general C problem. But even for the worst toolchains I have seen, dropping in a pair of .c/.h would not have been difficult. So it is st
More ›