tinycc-devel
[Top][All Lists]
Advanced

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

[Tinycc-devel] Divisions by zero in dead branches cause compiler errors


From: Petr Skočík
Subject: [Tinycc-devel] Divisions by zero in dead branches cause compiler errors
Date: Wed, 15 Jan 2020 15:18:36 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.1

I've just noticed `_Static_assert( !0 || 1/0, "");` fails to compile on
tinycc.

I had an overflow-checking macro expand to code like this and got a
compiler error from it on tinycc.

I've since changed the macro to have a redundant ternary in the divisor
(which works around the error and it should affect optimizing
compilers), but just in case somebody wants to fix this...

It seems to me like simply commenting out the

                if (const_wanted)
                    tcc_error("division by zero in constant");

at tccgen.c:2090 could do the trick.

Then we get a less specific "constant expression expected" instead of
"division by zero in constant" for  "enum { a = 1/0 };", but perhaps
fancy diagnostics are best left to big compilers.

Regards,
Petr Skocik



reply via email to

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