public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "zhkefa at live dot cn" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug sanitizer/106739] New: runtime error coredump case on c++17/20
Date: Thu, 25 Aug 2022 09:20:12 +0000	[thread overview]
Message-ID: <bug-106739-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 106739
           Summary: runtime error coredump case on c++17/20
           Product: gcc
           Version: 10.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: sanitizer
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zhkefa at live dot cn
                CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org,
                    jakub at gcc dot gnu.org, kcc at gcc dot gnu.org, marxin at gcc dot gnu.org
  Target Milestone: ---

code file test.cc:
=============================
class A {
public:
    A(int i): i(i){}
    int get() {return i;}
private:
    int i{0};
};

void func() {
    typedef int (A::*f)();
    f fs[] = {&A::get};
    A *a = new A{1};
    for (int i = 0; i < 1; ++i) {
        (a->*fs[i])();
    }
    delete a;
}

int main() {
    func();
    return 0;
}

===============
envirment: gcc10.4

g++ -fsanitize=address -fsanitize=undefined -std=c++17 test.cc

./a.out
runtime error: index 4198816 out of bounds for type func[1]
runtime error: load of address 0x7ffd97570f08 whith insufficient space for an
object of type 'long int'

if compile with -std=c++14 or -std=c++11, everything ok.

             reply	other threads:[~2022-08-25  9:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-25  9:20 zhkefa at live dot cn [this message]
2022-08-25 11:04 ` [Bug sanitizer/106739] [11/12/13 Regression] runtime error coredump case on c++17/20 since r11-2445-g8c00059ce058ea2a marxin at gcc dot gnu.org
2022-08-25 15:07 ` rguenth at gcc dot gnu.org
2022-10-19  7:08 ` [Bug sanitizer/106739] [10/11/12/13 " rguenth at gcc dot gnu.org
2022-12-02 13:19 ` jakub at gcc dot gnu.org
2022-12-02 13:41 ` marxin 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-106739-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).