public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "marxin at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/98549] [11 Regression] ICE in rs6000_emit_le_vsx_store, at config/rs6000/rs6000.c:9938 on powerpc64le-linux-gnu
Date: Tue, 19 Jan 2021 08:57:19 +0000	[thread overview]
Message-ID: <bug-98549-4-uELccPeHvl@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-98549-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #19 from Martin Liška <marxin at gcc dot gnu.org> ---
(In reply to Segher Boessenkool from comment #12)
> for (long i; i != compress_n_blocks; ++i)

It's not the code I pasted:

>  for (long i = 0; i < compress_n_blocks; ++i) {
>    unsigned char S[32], S2[32];

I initialized 'i' to zero.

> 
> "i" is uninitialized; accessing it is UB.  So this is ice-on-invalid.
> 
> I have no doubt there is an actual bug somewhere here.  We just do not
> have valid code yet as testcase (preferably shorter than this, and C
> code, so that it is easier and can run on more systems).

There's a code snippet that should not contain UBSAN:

extern "C" void *memcpy(void *, const void *, unsigned long);
inline void copy_mem(unsigned char *out, unsigned char *in, long n) {
  memcpy(out, in, n);
}
template <typename T> void typecast_copy(unsigned char out[], T in, long N) {
  memcpy(out, in, sizeof(T) * N);
}
template <typename T> void typecast_copy(T out, unsigned char in[], long N) {
  memcpy(out, in, sizeof(T) * N);
}

void encrypt_me(unsigned char *ptr);

unsigned char *xor_buf_in;
class BlockCipher {
public:
  void encrypt(unsigned char *ptr);
} * compress_n___trans_tmp_2;
class GOST_34_11 {
  void compress_n();
  BlockCipher m_cipher;
};

long compress_n_blocks = 0;
void GOST_34_11::compress_n() {
  for (long i = 0; i < compress_n_blocks; ++i) {
    unsigned char S[32], S2[32];
    char S_1;
    m_cipher.encrypt(S);
    S2[13] = S_1;
    long x[4], y[4];
    typecast_copy(x, S2, 4);
    x[0] ^= y[0];
    x[1] ^= y[1];
    x[2] ^= x[3];
    typecast_copy(S, x, 4);
    S2[0] = S[4] ^ S[6] ^ 4 ^ S[30];
    copy_mem(S, S + 2, 30);
    S[30] = S2[0];
    {
      long x[4];
      typecast_copy(x, S, 4);
      typecast_copy(y, xor_buf_in, 4);
      x[0] ^= y[0];
      typecast_copy(S, x, 4);
    }
    S2[4] = S[6];
    memcpy(compress_n___trans_tmp_2, S2, 32);
  }
}

int main()
{
  return 0;
}

  parent reply	other threads:[~2021-01-19  8:57 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-05 21:13 [Bug target/98549] New: " doko at debian dot org
2021-01-06  5:33 ` [Bug target/98549] " marxin at gcc dot gnu.org
2021-01-06  6:05 ` marxin at gcc dot gnu.org
2021-01-14 17:26 ` segher at gcc dot gnu.org
2021-01-14 19:25 ` jakub at gcc dot gnu.org
2021-01-15  1:58 ` segher at gcc dot gnu.org
2021-01-15  7:37 ` jakub at gcc dot gnu.org
2021-01-15  9:35 ` marxin at gcc dot gnu.org
2021-01-15 10:41 ` marxin at gcc dot gnu.org
2021-01-16 16:25 ` segher at gcc dot gnu.org
2021-01-16 16:29 ` segher at gcc dot gnu.org
2021-01-18  8:29 ` marxin at gcc dot gnu.org
2021-01-18 20:27 ` segher at gcc dot gnu.org
2021-01-18 23:04 ` jakub at gcc dot gnu.org
2021-01-18 23:19 ` segher at gcc dot gnu.org
2021-01-18 23:38 ` joseph at codesourcery dot com
2021-01-19  1:07 ` segher at gcc dot gnu.org
2021-01-19  1:54 ` segher at gcc dot gnu.org
2021-01-19  1:55 ` segher at gcc dot gnu.org
2021-01-19  8:57 ` marxin at gcc dot gnu.org [this message]
2021-01-19  8:59 ` marxin at gcc dot gnu.org
2021-01-19 23:28 ` segher at gcc dot gnu.org
2021-01-20 19:02 ` segher 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-98549-4-uELccPeHvl@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).