public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/108915] New: invalid pointer access preserved in optimized code
@ 2023-02-24  3:47 hiraditya at msn dot com
  2023-02-24  4:36 ` [Bug tree-optimization/108915] " pinskia at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: hiraditya at msn dot com @ 2023-02-24  3:47 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 108915
           Summary: invalid pointer access preserved in optimized code
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hiraditya at msn dot com
  Target Milestone: ---

Testcase has been reduced from u-boot's linker-list macro:
https://github.com/u-boot/u-boot/blob/master/include/linker_lists.h#L127


#include<stdio.h>

char* bar() {
    static char start_bar[0] __attribute__((aligned(16)))
       __attribute__((unused))
       __attribute__((section("__u_boot_list_2_1")));
    char *p = (char *)start_bar;
    for (int i = p[0]; i < p[9]; i++)
        printf("asdfasd");
    return 0;
}



$ gcc -O3 -fno-unroll-loops -S -o -

.LC0:
        .string "asdfasd"
bar:
        push    rbx
        movsx   eax, BYTE PTR start_bar.1[rip+9]
        movsx   ebx, BYTE PTR start_bar.1[rip]
        cmp     ebx, eax
        jge     .L2
.L3:
        mov     edi, OFFSET FLAT:.LC0
        xor     eax, eax
        add     ebx, 1
        call    printf
        movsx   eax, BYTE PTR start_bar.1[rip+9]
        cmp     eax, ebx
        jg      .L3
.L2:
        xor     eax, eax
        pop     rbx
        ret

-----------------------------------------------------
$ clang -O3 -fno-unroll-loops -S -o -

bar:                                    # @bar
        xor     eax, eax
        ret

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

end of thread, other threads:[~2023-03-23 22:27 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-24  3:47 [Bug c/108915] New: invalid pointer access preserved in optimized code hiraditya at msn dot com
2023-02-24  4:36 ` [Bug tree-optimization/108915] " pinskia at gcc dot gnu.org
2023-02-24  4:37 ` pinskia at gcc dot gnu.org
2023-02-24  4:39 ` pinskia at gcc dot gnu.org
2023-02-24  4:55 ` hiraditya at msn dot com
2023-02-24  5:06 ` pinskia at gcc dot gnu.org
2023-03-23 22:27 ` hiraditya at msn dot com

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