[Top][All Lists]

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

Re: [Tinycc-devel] MAJOR bug: tcc doesn't detect duplicate cases in swit

From: Daniel Glöckner
Subject: Re: [Tinycc-devel] MAJOR bug: tcc doesn't detect duplicate cases in switch statements
Date: Sat, 12 Mar 2016 20:02:42 +0100
User-agent: Mutt/1.5.20 (2009-06-14)

On Sat, Mar 12, 2016 at 10:58:42AM -0700, address@hidden wrote:
> The bug caused me to push bad code to gawk's repo. It's only luck that it
> wasn't noticed, but a bug is a bug.

So you have personal feelings towards that bug.

I'd never use TinyCC for serious development.
There are simply not enough testers.

> The issue isn't just the lack of diagnostic - what kind of erroneous
> code is being generated in this case?

Let's see what the final C11 draft (N1570) says about this issue:

Section paragraph 3:
The expression of each case label shall be an integer constant
expression and no two of the case constant expressions in the same
switch statement shall have the same value after conversion.

Section 4 paragraph 2:
If a "shall" or "shall not" requirement that appears outside of a
constraint or runtime-constraint is violated, the behavior is undefined.

There you read it, C11 allows us to generate whatever we want.

Regarding the cost of your solution, a tree structure might be faster
and could also be implemented in a way that handles value ranges.

Best regards,


reply via email to

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