public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "141242068 at smail dot nju.edu.cn" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/112494] New: GCC: 14: internal compiler error: in ix86_cc_mode, at config/i386/i386.cc:16477
Date: Sun, 12 Nov 2023 14:25:27 +0000	[thread overview]
Message-ID: <bug-112494-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 112494
           Summary: GCC: 14: internal compiler error: in ix86_cc_mode, at
                    config/i386/i386.cc:16477
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

Compiler Explorer: https://gcc.godbolt.org/z/cPPxenx7q

When compile this program with `-Og  -fno-tree-copy-prop -fno-tree-fre
-fno-tree-ccp -fno-tree-forwprop`, gcc crashes:
```
#include <x86intrin.h>

#ifdef __x86_64__
#  define EFLAGS_TYPE unsigned long long int
#else
#  define EFLAGS_TYPE unsigned int
#endif

int main() {
  EFLAGS_TYPE flags = 0xD7;
  __writeeflags(0xD7);
  flags && !__readeflags();
  if ((flags && (!__readeflags())) != 0xD7);
  return 0;
}
```

There are some intriguing observations about this crash.
1. Removing the `flags &&` portion at the point of the first __readeflags()
call eliminates the crash, even though it appears that `flags &&` has no
effect.
2. Removing the `!= 0xD7` portion at the point of the second __readeflags()
call also eliminates the crash.


The crash output:
```
during RTL pass: combine
<source>: In function 'main':
<source>:15:1: internal compiler error: in ix86_cc_mode, at
config/i386/i386.cc:16477
   15 | }
      | ^
0x238b15e internal_error(char const*, ...)
        ???:0
0xa11270 fancy_abort(char const*, int, char const*)
        ???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Compiler returned: 1
```

             reply	other threads:[~2023-11-12 14:25 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-12 14:25 141242068 at smail dot nju.edu.cn [this message]
2023-11-12 20:57 ` [Bug rtl-optimization/112494] " ubizjak at gmail dot com
2023-11-12 21:12 ` [Bug rtl-optimization/112494] ICE " pinskia at gcc dot gnu.org
2023-11-13  7:57 ` pinskia at gcc dot gnu.org
2023-11-13  8:50 ` ubizjak at gmail dot com
2023-11-13  8:52 ` [Bug target/112494] " ubizjak at gmail dot com
2023-11-13  9:54 ` ubizjak at gmail dot com
2023-11-13  9:59 ` ubizjak at gmail dot com
2023-11-13 10:51 ` ubizjak at gmail dot com
2023-11-13 21:47 ` cvs-commit at gcc dot gnu.org
2023-11-28 15:57 ` cvs-commit at gcc dot gnu.org
2023-11-28 16:00 ` ubizjak at gmail dot com

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-112494-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).