public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/109449] New: false positive stringop-overflow
@ 2023-04-08  7:35 pionere at freemail dot hu
  2023-04-08 21:37 ` [Bug middle-end/109449] " pinskia at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: pionere at freemail dot hu @ 2023-04-08  7:35 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 109449
           Summary: false positive stringop-overflow
           Product: gcc
           Version: 12.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pionere at freemail dot hu
  Target Milestone: ---

Compiling the following code:

#include <stdint.h>

#define DMAXX 40
#define DMAXY 40
#define DSIZEX 80
#define DSIZEY 80

typedef struct DrlgMem {
    union {
        uint8_t transvalMap[DMAXX][DMAXY];
        uint8_t transDirMap[DSIZEX][DSIZEY];
    };
} DrlgMem;

DrlgMem drlg;

void func()
{
    int i, j;
    uint8_t *tdp = &drlg.transDirMap[0][0];

    for (i = DMAXX - 1; i >= 0; i--) {
        for (j = DMAXY - 1; j >= 0; j--) {
            uint8_t tvm = drlg.transvalMap[i][j];
            uint8_t tpm = 0;
            // 1. subtile
            if (tvm & 1) {
                tpm = 14;
            } else {
                tpm = 0;
            }
            tdp[2 * i * DSIZEY + 2 * j] = tpm;
            // 3. subtile
            if (tvm & 4) {
                tpm = 25;
                if (tvm & (1 << 0)) // 1. subtile
                    tpm |= (1 << 1); // DIR_NW
                if (tvm & (1 << 3)) // 4. subtile
                    tpm |= (1 << 6); // DIR_SW
            } else {
                tpm = 0;
            }
            tdp[2 * i * DSIZEY + 2 * j + 1] = tpm;
            // 2. subtile
            if (tvm & 2) {
                tpm = 98;
            } else {
                tpm = 0;
            }
            tdp[(2 * i + 1) * DSIZEY + 2 * j] = tpm; // 1. warning here
            // 4. subtile
            if (tvm & 8) {
                tpm = 193;
            } else {
                tpm = 0;
            }
            tdp[(2 * i + 1) * DSIZEY + 2 * j + 1] = tpm; // 2. warning here
        }
    }
}

The result is multiple invalid warnings. E.g: '<source>:50:47: error: writing 1
byte into a region of size 0 [-Werror=stringop-overflow=]...'
Tried to reduce the sample code, but the warnings disappear even in case of
unrelated changes.

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

end of thread, other threads:[~2023-05-29 10:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-08  7:35 [Bug middle-end/109449] New: false positive stringop-overflow pionere at freemail dot hu
2023-04-08 21:37 ` [Bug middle-end/109449] " pinskia at gcc dot gnu.org
2023-04-08 21:40 ` pinskia at gcc dot gnu.org
2023-04-09  6:32 ` pionere at freemail dot hu
2023-04-12 13:54 ` [Bug middle-end/109449] [11/12/13 Regression] " rguenth at gcc dot gnu.org
2023-04-13  7:19 ` rguenth at gcc dot gnu.org
2023-05-29 10:08 ` [Bug middle-end/109449] [11/12/13/14 " jakub 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).