Andrew Pinski 0c3cc57f0e libstdc++: Improve list assumption after constructor [PR118865]
The code example here does:
```
if (begin == end) __builtin_unreachable();
std::list nl(begin, end);

for (auto it = nl.begin(); it != nl.end(); it++)
{
...
}
/* Remove the first element of the list. */
nl.erase(nl.begin());
```

And we get a warning because because we jump threaded the case were we
think the list was empty from the for loop BUT we populated it without
an empty array. So can help the compiler here by adding that after initializing
the list with non empty array, that the list will not be empty either.

This is able to remove the -Wfree-nonheap-object warning in the first reduced
testcase (with the fix for `begin == end` case added) in the PR 118865; the second
reduced testcase has been filed off as PR 118867.

Bootstrapped and tested on x86_64-linux-gnu.

libstdc++-v3/ChangeLog:

	PR libstdc++/118865
	* include/bits/stl_list.h (_M_initialize_dispatch): Add an
	unreachable if the iterator was not empty that the list will
	now be not empty.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2025-02-14 15:10:43 -08:00
2025-02-14 17:29:53 -05:00
2025-02-12 00:17:11 +00:00
2025-02-11 00:17:27 +00:00
2025-02-13 00:18:12 +00:00
2025-02-07 00:18:53 +00:00
2025-02-12 00:17:11 +00:00
2025-02-12 00:17:11 +00:00
2025-02-06 00:18:03 +00:00

This directory contains the GNU Compiler Collection (GCC).

The GNU Compiler Collection is free software.  See the files whose
names start with COPYING for copying permission.  The manuals, and
some of the runtime libraries, are under different terms; see the
individual source files for details.

The directory INSTALL contains copies of the installation information
as HTML and plain text.  The source of this information is
gcc/doc/install.texi.  The installation information includes details
of what is included in the GCC sources and what files GCC installs.

See the file gcc/doc/gcc.texi (together with other files that it
includes) for usage and porting information.  An online readable
version of the manual is in the files gcc/doc/gcc.info*.

See http://gcc.gnu.org/bugs/ for how to report bugs usefully.

Copyright years on GCC source files may be listed using range
notation, e.g., 1987-2012, indicating that every year in the range,
inclusive, is a copyrightable year that could otherwise be listed
individually.
Description
No description provided
Readme 4.2 GiB
Languages
C++ 30.7%
C 30.2%
Ada 14.4%
D 6.1%
Go 5.7%
Other 12.4%