public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "acoplan at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/113215] New: gimple FE can't handle static local variable with initializer
Date: Wed, 03 Jan 2024 11:49:08 +0000	[thread overview]
Message-ID: <bug-113215-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 113215
           Summary: gimple FE can't handle static local variable with
                    initializer
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: acoplan at gcc dot gnu.org
  Target Milestone: ---

The following testcase is accepted:

int __GIMPLE (ssa)
f ()
{
    static int x;
    __BB(2):
    return 1;
}

but adding an initializer to the static variable, it gets rejected:

$ cat > t.c
int __GIMPLE (ssa)
f ()
{
    static int x = 1;
    __BB(2):
    return 1;
}
$ gcc/xgcc -B gcc -c -fgimple t.c
t.c: In function ‘f’:
t.c:4:18: error: expected ‘;’ before ‘=’ token
    4 |     static int x = 1;
      |                  ^
t.c: At top level:
t.c:5:10: error: expected declaration specifiers or ‘...’ before numeric
constant
    5 |     __BB(2):
      |          ^
t.c:7:1: error: expected identifier or ‘(’ before ‘}’ token
    7 | }
      | ^

such IL can be generated by dumping optimized GIMPLE as seen e.g. with the
following testcase:

$ cat t2.c
int f() {
  static int x = 1;
  return x;
}
$ gcc/xgcc -B gcc -c t2.c -fdump-tree-optimized-gimple=-
int __GIMPLE (ssa)
f ()
{
  static int x = 1;
  int D_4434;
  int _2;

  __BB(2):
  _2 = x;
  goto __BB3;

  __BB(3):
L0:
  return _2;

}

             reply	other threads:[~2024-01-03 11:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-03 11:49 acoplan at gcc dot gnu.org [this message]
2024-01-08 14:43 ` [Bug c/113215] " rguenth at gcc dot gnu.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-113215-4@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).