tinycc-devel
[Top][All Lists]
Advanced

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

Re: [Tinycc-devel] Divisions by zero in dead branches cause compiler err


From: Michael Matz
Subject: Re: [Tinycc-devel] Divisions by zero in dead branches cause compiler errors
Date: Wed, 15 Jan 2020 23:39:09 +0100 (CET)
User-agent: Alpine 2.21 (LSU 202 2017-01-01)

Hello,

On Wed, 15 Jan 2020, Petr Skočík wrote:

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

Thanks for the report, that shows that unevaluated sub-expressions of const expressions were mishandled. We also diagnosed (incorrectly)

  static int i = 2 || 1 / 0;

(which even is literally written down in the standard).

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.

Yeah, I've chosen a more complete solution, so that the latter is still diagnosed, but the former isn't.


Ciao,
Michael.

reply via email to

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