[Top][All Lists]

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

Re: [Tinycc-devel] [PATCH] tcc: remove buggy nodata_wanted optimization

From: Michael Matz
Subject: Re: [Tinycc-devel] [PATCH] tcc: remove buggy nodata_wanted optimization
Date: Fri, 23 Feb 2018 22:57:46 +0100 (CET)
User-agent: Alpine 2.20 (LSU 67 2015-01-07)


On Thu, 22 Feb 2018, grischka wrote:

However NODATA_WANTED does more than that, for example it also suppresses
the "hello" with
        if (0) puts("hello");

Therefor I'd suggest a less radical change, such as:

@@ -6916,7 +6916,7 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r,
        align = 1;

+    if (!v && NODATA_WANTED)
        size = 0, align = 1;

    if ((r & VT_VALMASK) == VT_LOCAL) {

Thus variable space will be allocated always but initializers are
still suppressed.  (Bypassing initializers with goto is not allowed).

For statics it is. E.g. the following program is valid and must print 42:

#include <stdio.h>
int main() {
  goto doit;
  if (0) {
    static int a = 42;
    printf ("%d\n", a);

But the idea of supressing only nameless entities is a good one I think.


reply via email to

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