-
-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Testing with cpp_ reference examples #106
Comments
Also trying to test with
|
The error here is because the include dir (gcc and system headers) are not configured
Create a //Edit this file adding inside pragma dir "" .. the result of #pragma dir "add dir here..." Next time you run cake
Then the includes configured inside (The same on windows) See "Include directories" On windows. I have created this repository with real source code to be checked |
Using
Then applying this fix:
Then:
|
( |
Looking through the usage (see bellow) of
Because here Line 1794 in d503e53
memcpy ) .
|
Attached is the output of running
|
a zip with source code only (.c) would help.
I don't have lua installed or lua experience.
Initially I was using unittest with files, but then I changed to use
"embedded" source code,
because it was faster to check.
But we can have both approaches like having a folder 100% with code that
should compile ok.
…On Fri, 23 Feb 2024 at 07:31, Domingo Alvarez Duarte < ***@***.***> wrote:
Attached is the output of running test-c-reference.lua , it includes the
extracted code for the ones that fail.
Total files scanned : 611
Total files with code : 432
Total files failed code : 129
test-c-reference.lua.log.zip
<https://github.com/thradams/cake/files/14384173/test-c-reference.lua.log.zip>
—
Reply to this email directly, view it on GitHub
<#106 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABSMZLTVTAH4LONCA26PNRTYVBVXJAVCNFSM6AAAAABDRFHAL6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRRGA4DEMRRGI>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
The zip file is the output of running the |
Here is a simplified code that
|
In the zip file search for |
This mingodad@9294ae7 temporary fix allow more files to be parsed. |
I found this two minimal examples that show a bug in
This one that do not use an intermediate variable fail:
Output:
|
With this fix mingodad@603abc4 I could get
After (lua "test-c-reference.lua"):
|
With this sample:
And with this fix mingodad@a4bcf34 we get:
Before it was:
|
With this fix mingodad@5e61573 :
Output:
Before:
|
With this temporary fix mingodad@0a59d95 :
Output:
Before:
This pattern in
|
This mingodad@aa07dbd fix the UTF8 range assert that was failing with the sample bellow:
|
hi I believe
print_type_specifier_flags
from you branch is wrong because we can have like unsigned int two
specifiers.
so if else is wrong.
…On Sat, 24 Feb 2024 at 14:20, Domingo Alvarez Duarte < ***@***.***> wrote:
This ***@***.***
<mingodad@aa07dbd>
fix the UTF8 range assert that was failing with the sample bellow:
#include <errno.h>
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <wchar.h>
int main(void)
{
setlocale(LC_ALL, "en_US.utf8");
errno = 0;
if (fputwc(L'🍌', stdout) == WEOF)
{
if (errno == EILSEQ)
puts("Encoding error in fputwc.");
else
puts("I/O error in fputwc.");
return EXIT_FAILURE;
}
}
—
Reply to this email directly, view it on GitHub
<#106 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABSMZLU2BTA2KM3DMTECRB3YVIOPDAVCNFSM6AAAAABDRFHAL6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRSGQZDONRYGE>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Thank you for reply ! |
This fix mingodad@b3c7c11 memory use after free detected by
Before the fix:
After the fix:
|
I did a checkin with a pattern that I think it is better with fails like malloc inside try blocks I want to return null to avoid ignoring half catch
{
if (p_expression_node)
{
expression_node_delete(p_expression_node);
p_expression_node = NULL;
}
} double free is fixed just puting new_expression->left = p_expression_node;
p_expression_node = NULL; /*MOVED*/ after moving it |
did you see the option -DTEST on build?
When we fix some problem is good to add a test case in tests.c that covers
the problems.
then we avoid regressions.
…On Sun, 25 Feb 2024 at 06:29, Domingo Alvarez Duarte < ***@***.***> wrote:
This fix ***@***.***
<mingodad@b3c7c11>
memory use after free detected by valgrind when parsing this sample:
#include <stdio.h>
#include <complex.h>
#include <math.h>
int main(void)
{
double complex z1 = 0.0 + INFINITY * _Imaginary_I;
printf("z1 = %.1f%+.1fi\n", creal(z1), cimag(z1));
double complex z2 = 0.0 + INFINITY * _Complex_I;
printf("z2 = %.1f%+.1fi\n", creal(z2), cimag(z2));
}
Before the fix:
src/cake /tmp/cCode.c
free(): double free detected in tcache 2
timeout: the monitored command dumped core
Command terminated by signal 6
After the fix:
src/cake /tmp/cCode.c
Cake 0.7.4
/tmp/cCode.c
/tmp/cCode.c:7:42: error: not found '_Imaginary_I'
7 | double complex _Complex z1 = 0.0 + INFINITY 1e10000f * _Imaginary_I;
| ^~~~~~~~~~~~
/tmp/cCode.c:7:42: error: right * is not arithmetic
7 | double complex _Complex z1 = 0.0 + INFINITY 1e10000f * _Imaginary_I;
| ^~~~~~~~~~~~
/tmp/cCode.c:7:42: error: invalid type multiplicative expression
7 | double complex _Complex z1 = 0.0 + INFINITY 1e10000f * _Imaginary_I;
| ^~~~~~~~~~~~
/tmp/cCode.c:7:42: error: expected TK_SEMICOLON
7 | double complex _Complex z1 = 0.0 + INFINITY 1e10000f * _Imaginary_I;
| ^~~~~~~~~~~~
—
Reply to this email directly, view it on GitHub
<#106 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABSMZLRWX4Z2BSMYG5IB2ETYVMABFAVCNFSM6AAAAABDRFHAL6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRSHA3TANRSGY>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
a zip with all .c would be useful.
the same code can compile on linux and not compile on windows for instance.
the includes and the behavior is different
it also can work as regression test.
…On Fri, 23 Feb 2024 at 09:35, Domingo Alvarez Duarte < ***@***.***> wrote:
The zip file is the output of running the Lua script, you can see the
errors and the source code for the failures direct there (no need to to run
the script yourself).
—
Reply to this email directly, view it on GitHub
<#106 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABSMZLTRIIJKSZS2S75LJGTYVCEHTAVCNFSM6AAAAABDRFHAL6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRRGI2TAMRTGM>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Here it's a zip with all examples extracted. |
many thanks!
I will try to use it as unit tests.
…On Sun, 25 Feb 2024 at 09:14, Domingo Alvarez Duarte < ***@***.***> wrote:
Here it's a zip with all examples extracted.
en-cpp-reference-c.zip
<https://github.com/thradams/cake/files/14396325/en-cpp-reference-c.zip>
—
Reply to this email directly, view it on GitHub
<#106 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABSMZLV6YS3C7MGU6CD5OFDYVMTJ5AVCNFSM6AAAAABDRFHAL6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRSHEYTMNJYG4>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
ccode424.c is failing..but nullptr_t is a typedef. void puts(const char*);
#define DETECT_NULL_POINTER_CONSTANT(e) \
_Generic(e, \
void* : puts("void*"), \
nullptr_t : puts("nullptr_t"), \
default : puts("other") \
)
int main()
{
DETECT_NULL_POINTER_CONSTANT(((void*)0));
DETECT_NULL_POINTER_CONSTANT(0);
DETECT_NULL_POINTER_CONSTANT(nullptr);
} I think cake is correct. |
Why do you have |
The reason I kept tests/en-cpp-reference-c/out is to compare the code generation ouput. |
Most of errors now are from imaginary samples that where not implemented. |
sqlite is compiling. assert assert can be fixed. it was used for instance void flow_visit_ctx_destroy(struct flow_visit_ctx* obj_owner p)
{
assert(p->tail_block == NULL);
} it works at same time as runtime and static information. |
ouput I added cakeconfig.h at src
|
Great work !
|
Not sure, but probably it is because comments, spaces, inactive preprocessor blocks are preserved to be able to generate the "c backend" . |
Also for comparison https://github.com/rui314/chibicc uses more memory than
And
|
TCC is one pass I think Cake has the ast used in second passa.But the main problem must be the tokens that are not discarded Em 25 de fev. de 2024, à(s) 16:24, Domingo Alvarez Duarte ***@***.***> escreveu:
Also for comparison https://github.com/rui314/chibicc uses more memory than cake when compiling sqlite3.c:
chibicc -c sqlite3.c
2.59user 0.37system 0:02.97elapsed 99%CPU (0avgtext+0avgdata 525964maxresident)k
0inputs+6336outputs (0major+201446minor)pagefaults 0swaps
And tinycc uses almost nothing compared to the others:
/usr/bin/time tcc -c sqlite3.c
0.09user 0.01system 0:00.11elapsed 93%CPU (0avgtext+0avgdata 16748maxresident)k
840inputs+3696outputs (2major+3726minor)pagefaults 0swaps
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: ***@***.***>
|
A lot of samples using imaginary. |
nullptr_t is suppose to be a typedef and it is used as builtin type on samples |
alignas error |
individual errors will be created. asm, align errors already exist. |
Using a
Lua
script shown bellow we can testcake
against the examples in https://en.cppreference.com/w/c that can be downloaded for offline view here https://en.cppreference.com/w/Cppreference:Archives .The text was updated successfully, but these errors were encountered: