public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "gabravier at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/29970] mixing ({...}) with VLA leads to massive breakage
Date: Fri, 26 Jan 2024 01:01:41 +0000	[thread overview]
Message-ID: <bug-29970-4-KdZGBcNR4R@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-29970-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=29970

Gabriel Ravier <gabravier at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |gabravier at gmail dot com

--- Comment #19 from Gabriel Ravier <gabravier at gmail dot com> ---
Can also confirm this myself as I've also encountered this ICE in this code:

#include <stdio.h>

#define each(item, array) \
(typeof(*(array)) *foreach_p = (array), *foreach_p2 = foreach_p, (item) = {}; \
foreach_p < &((foreach_p2)[sizeof(array)/sizeof(*array)]); \
++foreach_p)if((__builtin_memcpy(&(item), foreach_p, sizeof((item)))), 0){}else

#define range1(_stop) (({ \
        typeof(_stop) stop = _stop; \
        struct{typeof((stop)) array[stop];}p = {}; \
        if(stop < 0){ \
                for(size_t i = 0; i > stop; --i) \
                        p.array[-i] = i; \
        }else{ \
                for(size_t i = 0; i < stop; ++i) \
                        p.array[i] = i; \
        } \
        p; \
}).array)

int main(){
        char group[][4] = {
                "egg",
                "one",
                "two",
                "moo",
        };
        for each(x, group){
                puts(x);
        }
        return sizeof(range1(6));
}

which I was able to minify to:

void f()
{
  (void)({
    int x = 1;
    struct {
      int array[x];
    } p;
    p;
  });
}

which roughly matches what testcase 2 does.

  parent reply	other threads:[~2024-01-26  1:01 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-29970-4@http.gcc.gnu.org/bugzilla/>
2021-03-23 19:33 ` pinskia at gcc dot gnu.org
2021-03-23 19:45 ` tunagul29 at icloud dot com
2021-08-03 18:12 ` muecker at gwdg dot de
2021-08-05 18:25 ` muecker at gwdg dot de
2021-08-10  5:50 ` cvs-commit at gcc dot gnu.org
2021-08-12 18:37 ` cvs-commit at gcc dot gnu.org
2021-08-14 20:03 ` muecker at gwdg dot de
2021-09-04 19:55 ` muecker at gwdg dot de
2021-09-05 19:16 ` muecker at gwdg dot de
2021-11-07 11:57 ` muecker at gwdg dot de
2021-11-17 13:30 ` cvs-commit at gcc dot gnu.org
2023-05-31  2:20 ` egallager at gcc dot gnu.org
2023-05-31  5:01 ` muecker at gwdg dot de
2024-01-26  1:01 ` gabravier at gmail dot com [this message]
2006-11-24 12:36 [Bug c/29970] New: " aviro at redhat dot com
2006-11-24 13:57 ` [Bug c/29970] " joseph at codesourcery dot com
2006-11-24 15:25 ` aviro at redhat dot com
2006-11-25  1:55 ` pinskia at gcc dot gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-29970-4-KdZGBcNR4R@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).