Repository navigation
Commit c638ddf
tccgen: reject pointer/function-pointer to floating-point conversions
C11 6.3.2.3 and 6.5.4 forbid both implicit and explicit conversions
between pointers (including function pointers) and floating-point
types. verify_assign_cast() and gen_cast() were silently allowing
them by treating the pointer value as an integer, so code like
double a = "foo";
double b = (double)main;
compiled and produced the address converted to a double.
Add the missing checks in verify_assign_cast() and gen_cast() so
these are diagnosed at compile time, and extend the
60_errors_and_warnings test with three cases covering implicit
conversion, explicit cast, and function-pointer argument.
Reported on the tinycc-devel mailing list:
https://lists.nongnu.org/archive/html/tinycc-devel/2026-09/msg00016.html1 parent 2d3eea2 commit c638ddf
3 files changed
Lines changed: 41 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3297 | 3297 | | |
3298 | 3298 | | |
3299 | 3299 | | |
| 3300 | + | |
| 3301 | + | |
3300 | 3302 | | |
3301 | 3303 | | |
3302 | 3304 | | |
| |||
3697 | 3699 | | |
3698 | 3700 | | |
3699 | 3701 | | |
| 3702 | + | |
| 3703 | + | |
| 3704 | + | |
| 3705 | + | |
| 3706 | + | |
| 3707 | + | |
| 3708 | + | |
3700 | 3709 | | |
3701 | 3710 | | |
3702 | 3711 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
698 | 698 | | |
699 | 699 | | |
700 | 700 | | |
| 701 | + | |
701 | 702 | | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
702 | 725 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
305 | 305 | | |
306 | 306 | | |
307 | 307 | | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
0 commit comments