public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/109895] New: -Walloc-size-larger-than complains about code it generated itself under -flto -fno-exceptions
@ 2023-05-17 18:07 thiago at kde dot org
2023-05-17 18:22 ` [Bug tree-optimization/109895] " pinskia at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: thiago at kde dot org @ 2023-05-17 18:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109895
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 = mysql_stmt_param_count(d->stmt);
if (paramCount > 0) // allocate memory for outvalues
d->outBinds = 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 ‘prepare’:
src/plugins/sqldrivers/mysql/qsql_mysql.cpp:891:50: warning: argument 1 value
‘18446744073709551615’ exceeds maximum object size 9223372036854775807
[-Walloc-size-larger-than=]
891 | d->outBinds = new MYSQL_BIND[paramCount]();
| ^
/usr/include/c++/13/new:128:26: note: in a call to allocation function
‘operator new []’ 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.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-05-17 18:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-17 18:07 [Bug c++/109895] New: -Walloc-size-larger-than complains about code it generated itself under -flto -fno-exceptions thiago at kde dot org
2023-05-17 18:22 ` [Bug tree-optimization/109895] " pinskia 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).