From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B0E553858C5E; Wed, 17 May 2023 18:07:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B0E553858C5E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1684346853; bh=XrZEgCVLqevkzfQEx8GBpfpSn1zXExrlpFHCHhZd0Tk=; h=From:To:Subject:Date:From; b=XMweYJ2kkoToSTd0PeIwn30tNqOexDsg9eGJh6zYh7BoEHoYknG5yQGxQkvDa+8M1 1NRG/N49mEPbtCgRGVW9faytCsSqRZ+AsSun/n0o7XjJyqqCQD/x5OvlT00G/v4A5A nwpc2KURx859hmmZuJvjiD8OncLRJ19Q8K+KhC38= From: "thiago at kde dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/109895] New: -Walloc-size-larger-than complains about code it generated itself under -flto -fno-exceptions Date: Wed, 17 May 2023 18:07:33 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 13.1.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: thiago at kde dot org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D109895 Bug ID: 109895 Summary: -Walloc-size-larger-than complains about code it generated itself under -flto -fno-exceptions Product: gcc Version: 13.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: thiago at kde dot org Target Milestone: --- Reference: https://bugreports.qt.io/browse/QTBUG-113603 Code in question: const auto paramCount =3D mysql_stmt_param_count(d->stmt); if (paramCount > 0) // allocate memory for outvalues d->outBinds =3D new MYSQL_BIND[paramCount](); mysql_stmt_param_count returns unsigned long. GCC 13.1 with -flto -fno-exceptions produced: src/plugins/sqldrivers/mysql/qsql_mysql.cpp: In member function =E2=80=98pr= epare=E2=80=99: src/plugins/sqldrivers/mysql/qsql_mysql.cpp:891:50: warning: argument 1 val= ue =E2=80=9818446744073709551615=E2=80=99 exceeds maximum object size 92233720= 36854775807 [-Walloc-size-larger-than=3D] 891 | d->outBinds =3D new MYSQL_BIND[paramCount](); | ^ /usr/include/c++/13/new:128:26: note: in a call to allocation function =E2=80=98operator new []=E2=80=99 declared here 128 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^ Disassembling the code shows it looks similar to this: https://godbolt.org/z/9eKPxbEMY movq $-1, %rdi cmpq %rbx, %rax jb .L2 ... .L2: call operator new[](unsigned long)@PLT So that 18446744073709551615 value is the -1 inserted by GCC itself to deal with the multiplication overflow.=