tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] Possible bug in _Generic code, need help to get it fi


From: K K
Subject: Re: [Tinycc-devel] Possible bug in _Generic code, need help to get it fixed
Date: Mon, 24 Feb 2020 15:58:32 +0000

Thanks for this solution, UnknownGamer. I know you discovered this Problem already some time ago. This works for me, so I use this temporary 😊

 

Von: UnknownGamer40464 .
Gesendet: Freitag, 21. Februar 2020 22:37
An: address@hidden
Betreff: Re: [Tinycc-devel] Possible bug in _Generic code, need help to get it fixed

 

Not really a solution, but I've found that you can work around it like this:

 

```c
#include <stdio.h>

#define numeric_str(X)\
_Generic((X),\
    double: "double",\
    default:\
        _Generic((X)\
            long double: "long double",\
            int: "int",\
            float: "float",\
            default: "not a numeric type"\
        )\
)

int main(void){
    puts(numeric_str(3.14L));
}

```

 

should print "double" on tcc and work correctly on others, so at least it'll compile.

 

On Fri, Feb 21, 2020 at 10:48 AM K K <address@hidden> wrote:
>
> Hello all,
>
> I got the error message "type match twice" using the following code (built tcc from HEAD, running on Windows 10 64 bit):
>
> #include <stdio.h>
> void main() {
>     const double d = 0;
>     printf(_Generic((d), double: "%g", long double: "%Lg", default: "<unknown>"), d);
> }
>
> The same problem was already mentioned  https://lists.gnu.org/archive/html/tinycc-devel/2019-08/msg00012.html.
>
> I'm not perfectly in knowing the tcc sources, but in my opinion I discovered the source of this problem at line https://repo.or.cz/tinycc.git/blob/HEAD:/tccgen.c#l4591 and the following line, which changes a correctly parsed type "long double" back to "double" and so leads at line https://repo.or.cz/tinycc.git/blob/HEAD:/tccgen.c#l5433 and some following lines to the incorrect assumption, that the _Generic definition contains two controlling expressions of the same type. This change was done
> back in 2017 by grischka during a long review https://repo.or.cz/tinycc.git/commit/1443039416dd02750765efde1af35e31c8d41be3.
>
> I cannot determine if https://repo.or.cz/tinycc.git/blob/HEAD:/tccgen.c#l4592 is wrong because I do not know the intension why it was added. And I do not know why this type change is done only for PE targets, too. So maybe grischka or someone with more knowledge about the tcc sources is able to check this again or someone can point me in further directions.
>
> Thanks in advance,
> Kernel
> _______________________________________________
> Tinycc-devel mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/tinycc-devel

 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]