Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
thradams
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
8 ms
·
31.
▲
by
thradams
3y ago
It works in both ways. We can just tell the compiler to ignore some function. We can be also creative writing the code that at same time is good and makes the static analysis happy. A good sample is linked lists. #include <ownersh
32.
▲
by
thradams
3y ago
Everything related to safety is on my list. (the list is big) I think big problems can be broken down into smaller ones.
33.
▲
by
thradams
3y ago
The ownership works for non pointers. We can have integers (handles) that are owners. This allow custom allocators for instance. The concept of owner is some value that works as reference to an object and manages its lifetime.
34.
▲
by
thradams
3y ago
Static analysis has a significant advantage over runtime checks for memory leaks, especially in code that is almost never executed, because bugs can remain hidden until they appear in production. The code where I found the bug last year was
35.
▲
by
thradams
3y ago
The real experience so far is the cake source itself.
36.
▲
by
thradams
3y ago
The analysis can be disabled or silenced in some functions. the "static state" also can be override. (see the realloc sample) Because this is C, the programmers can do wherever they want, but before it must do some negotiation wit
37.
▲
by
thradams
3y ago
Converting code can be challenging. The cake code has been successfully converted. null-checks are not ready, and something similar already happened to c#. The experience is similar to changing a header file to use a const argument where pr
38.
▲
by
thradams
3y ago
"uninitialized memory" and "null checks" is part of flow analysis. UB and out of bound is not part of it.
39.
▲
by
thradams
3y ago
The answer you can have the same source code and compile with gcc, but only cake is implementing the checks at this moment. The have the same source code compiling in any compiler a header ownership.h is used to define owner etc as empty ma
40.
▲
by
thradams
3y ago
Cake is a C23 front end, but it can also be used as a static analysis tool. The qualifiers can be empty macros then the same code can be compiled with gcc , clang and the static analysis of ownership can be using cake. Inside visual studio
41.
▲
Static Ownership Checks for C
(thradams.com)
2 points
by
thradams
3y ago
|
1 comments
42.
▲
by
thradams
3y ago
Cake is a C23 Front End http://thradams.com/cake/index.html that is implementing static ownership checks. Cake source itself is already using this feature that can be used and disabled with few macros. The link is a to
43.
▲
Experimental static ownership checks for C
(thradams.com)
4 points
by
thradams
3y ago
|
1 comments
44.
▲
by
thradams
3y ago
I am currently experimenting with static ownership checks for C, aiming to provide guarantees that resources are released when necessary. As this is a work in progress, bugs are expected. More flow analysis is required. Despite that, you ca
45.
▲
by
thradams
4y ago
To remove comments from source all you need is a tokenizer. You don't need all the tokens, just the "preprocessor tokens". For instance literal strings, ppnumbers ... Then / comments / can be replaced with 1 space a
46.
▲
by
thradams
4y ago
Wow this is really bad! This was my first topic here in hacker news. I wasn't expecting all this traffic. Good to see and find more people interested in this kind of project. I will be more careful in the future.
47.
▲
by
thradams
4y ago
Yes! I am Brazilian.
48.
▲
by
thradams
4y ago
The declaration of puts is missing at the stdio.h used by the web version. (If you output preprocessed you will see the declarations are there) I will added it. Thanks. Meanwhile you can add: int puts( const char *str );
49.
▲
by
thradams
4y ago
My goal with the transpiler is not only the transpiler, although my front end had to be created differently of an normal compiler and preserve more tokens that could be discarded during the compilation. This also can be useful for a tool th
50.
▲
by
thradams
4y ago
It's a front end. The backend implemented generates C code. I hope to have other backends in the future.
51.
▲
by
thradams
4y ago
The part that is the "transpiler" is visit.c and visit.h. You can use it as reference to create different "visits". For instance, I am implementing a code format at "visitformat.c". I have implemented a "
52.
▲
by
thradams
4y ago
Everything that is not part of C23 I annotated with "extension". For instance "Extension Defer" or "Extension Lambda" are not part of C23.
53.
▲
by
thradams
4y ago
Even having experience with C/C++, C preprocessor and C declarations took a long time. Some time to get used to the grammar as well. A language without preprocessor and a simple grammar saves a lot time and you can go direct for the fu
54.
▲
by
thradams
4y ago
thanks! :D
55.
▲
by
thradams
4y ago
This is my hobby project of a C23 Front End. One of its unique features is the transpiler that can generate readable code, preserving macros and formatting. See it online: http://thradams.com/web3/playground.html
56.
▲
Cake – A C23 compiler frond end written from scratch in C
(github.com)
212 points
by
thradams
4y ago
|
52 comments