public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/102511] New: GCC produces incorrect code for -O3: first element of the array is skipped
@ 2021-09-28  3:11 vsevolod.livinskij at frtk dot ru
  2021-09-28  4:24 ` [Bug tree-optimization/102511] [12 Regression] " pinskia at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: vsevolod.livinskij at frtk dot ru @ 2021-09-28  3:11 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 102511
           Summary: GCC produces incorrect code for -O3: first element of
                    the array is skipped
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vsevolod.livinskij at frtk dot ru
  Target Milestone: ---

Reproducer:
//func.cpp
extern char arr_15[];
void test(signed char a, unsigned short b, unsigned long long c,
          unsigned short f) {
  for (int d = b - 8; d < b; d += 2)
    for (short e = 0; e < (unsigned short)((f ? 122 : 0) ^ (a ? c : 0)) -
64055;
         e += 3)
      arr_15[d] = 42;
}

//driver.cpp 
#include <stdio.h>

unsigned char arr_15 [8];

void test(signed char a, unsigned short b, unsigned long long int c, unsigned
short f);

int main() {
    test(37, 8, 12325048486467861044ULL, 45936);
    for (size_t i_0 = 0; i_0 < 8; ++i_0)
            printf("%d ", arr_15 [i_0]);
    printf("\n");
}

Error:
>$ g++ -O3 driver.cpp func.cpp && ./a.out 
0 0 42 0 42 0 42 0 
>$ g++ -O2 driver.cpp func.cpp && ./a.out 
42 0 42 0 42 0 42 0 

GCC version:

Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/testing/gcc/bin/libexec/gcc/x86_64-pc-linux-gnu/12.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /testing/gcc/gcc_src/configure --enable-multilib
--prefix=/testing/gcc/bin --disable-bootstrap
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 12.0.0 20210927 (51018dd1395c72b3681ae5f84eceb94320472922) (GCC)

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2021-09-28 14:51 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-28  3:11 [Bug tree-optimization/102511] New: GCC produces incorrect code for -O3: first element of the array is skipped vsevolod.livinskij at frtk dot ru
2021-09-28  4:24 ` [Bug tree-optimization/102511] [12 Regression] " pinskia at gcc dot gnu.org
2021-09-28  4:33 ` pinskia at gcc dot gnu.org
2021-09-28  4:37 ` pinskia at gcc dot gnu.org
2021-09-28  5:23 ` pinskia at gcc dot gnu.org
2021-09-28  5:37 ` [Bug tree-optimization/102511] [12 Regression] GCC produces incorrect code for -O3: first element of the array is skipped after r12-3903 pinskia at gcc dot gnu.org
2021-09-28  7:36 ` aldyh at gcc dot gnu.org
2021-09-28  7:44 ` pinskia at gcc dot gnu.org
2021-09-28  9:12 ` cvs-commit at gcc dot gnu.org
2021-09-28  9:19 ` aldyh at gcc dot gnu.org
2021-09-28 14:51 ` aldyh at gcc dot gnu.org

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