glibc/malloc
Joseph Myers 7ca9377bab Disable -Waggressive-loop-optimizations warnings in tst-dynarray.c
My build-many-glibcs.py bot shows -Waggressive-loop-optimizations
errors building the glibc testsuite for 32-bit architectures with GCC
mainline, which seem to have appeared between GCC commits
4abc0c196b10251dc80d0743ba9e8ab3e56c61ed and
d8edfadfc7a9795b65177a50ce44fd348858e844:

In function 'dynarray_long_noscratch_resize',
    inlined from 'test_long_overflow' at tst-dynarray.c:489:5,
    inlined from 'do_test' at tst-dynarray.c:571:3:
../malloc/dynarray-skeleton.c:391:36: error: iteration 1073741823 invokes undefined behavior [-Werror=aggressive-loop-optimizations]
  391 |             DYNARRAY_ELEMENT_INIT (&list->u.dynarray_header.array[i]);
tst-dynarray.c:39:37: note: in definition of macro 'DYNARRAY_ELEMENT_INIT'
   39 | #define DYNARRAY_ELEMENT_INIT(e) (*(e) = 23)
      |                                     ^
In file included from tst-dynarray.c:42:
../malloc/dynarray-skeleton.c:389:37: note: within this loop
  389 |         for (size_t i = old_size; i < size; ++i)
      |                                   ~~^~~~~~
In function 'dynarray_long_resize',
    inlined from 'test_long_overflow' at tst-dynarray.c:479:5,
    inlined from 'do_test' at tst-dynarray.c:571:3:
../malloc/dynarray-skeleton.c:391:36: error: iteration 1073741823 invokes undefined behavior [-Werror=aggressive-loop-optimizations]
  391 |             DYNARRAY_ELEMENT_INIT (&list->u.dynarray_header.array[i]);
tst-dynarray.c:27:37: note: in definition of macro 'DYNARRAY_ELEMENT_INIT'
   27 | #define DYNARRAY_ELEMENT_INIT(e) (*(e) = 17)
      |                                     ^
In file included from tst-dynarray.c:28:
../malloc/dynarray-skeleton.c:389:37: note: within this loop
  389 |         for (size_t i = old_size; i < size; ++i)
      |                                   ~~^~~~~~

I don't know what GCC change made these errors appear, or why they
only appear for 32-bit architectures.  However, the warnings appear to
be both true (that iteration would indeed involve undefined behavior
if executed) and useless in this particular case (that iteration is
never executed, because the allocation size overflows and so the
allocation fails - but the check for allocation size overflow is in a
separate source file and so can't be seen by the compiler when
compiling this test).  So use the DIAG_* macros to disable
-Waggressive-loop-optimizations around the calls in question to
dynarray_long_resize and dynarray_long_noscratch_resize in this test.

Tested with build-many-glibcs.py (GCC mainline) for arm-linux-gnueabi,
where it restores a clean testsuite build.
2021-10-29 14:40:45 +00:00
..
alloc_buffer_alloc_array.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
alloc_buffer_allocate.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
alloc_buffer_copy_bytes.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
alloc_buffer_copy_string.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
alloc_buffer_create_failure.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
arena.c misc: Add __get_nprocs_sched 2021-09-27 09:13:06 -03:00
Depend added rt to malloc/Depend [BZ #27132] 2021-02-23 10:04:45 +01:00
dynarray_at_failure.c malloc: Sync dynarray with gnulib 2021-02-09 16:57:54 -03:00
dynarray_emplace_enlarge.c malloc: Sync dynarray with gnulib 2021-02-09 16:57:54 -03:00
dynarray_finalize.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
dynarray_resize_clear.c malloc: Sync dynarray with gnulib 2021-02-09 16:57:54 -03:00
dynarray_resize.c malloc: Sync dynarray with gnulib 2021-02-09 16:57:54 -03:00
dynarray-skeleton.c malloc: Sync dynarray with gnulib 2021-02-09 16:57:54 -03:00
dynarray.h malloc: Sync dynarray with gnulib 2021-02-09 16:57:54 -03:00
hooks.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
Makefile tst-mxfast: Don't run with mcheck 2021-08-05 07:36:55 +05:30
malloc-check.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
malloc-debug.c Handle NULL input to malloc_usable_size [BZ #28506] 2021-10-29 14:53:55 +05:30
malloc-internal.h Add a generic malloc test for MALLOC_ALIGNMENT 2021-07-09 06:39:30 -07:00
malloc.c Handle NULL input to malloc_usable_size [BZ #28506] 2021-10-29 14:53:55 +05:30
malloc.h Add alloc_align attribute to memalign et al 2021-10-21 00:19:20 +01:00
mallocbug.c Reformat malloc to gnu style. 2014-01-02 09:40:10 +01:00
mcheck-impl.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
mcheck-init.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
mcheck.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
mcheck.h Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
memusage.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
memusage.sh Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
memusagestat.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
morecore.c Remove __morecore and __default_morecore 2021-07-22 18:37:57 +05:30
mtrace-impl.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
mtrace.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
mtrace.pl Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
obstack.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
obstack.h Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
reallocarray.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
scratch_buffer_dupfree.c malloc: Add scratch_buffer_dupfree 2021-01-05 11:33:16 -03:00
scratch_buffer_grow_preserve.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
scratch_buffer_grow.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
scratch_buffer_set_array_size.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
set-freeres.c nptl: Move stack cache management, __libpthread_freeres into libc 2021-05-11 11:22:33 +02:00
thread-freeres.c dlfcn: dlerror needs to call free from the base namespace [BZ #24773] 2021-04-21 19:49:51 +02:00
tst-alloc_buffer.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
tst-calloc.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
tst-compathooks-off.c Move malloc hooks into a compat DSO 2021-07-22 18:37:59 +05:30
tst-compathooks-on.c Move malloc hooks into a compat DSO 2021-07-22 18:37:59 +05:30
tst-dynarray-at-fail.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
tst-dynarray-fail.c malloc: Sync dynarray with gnulib 2021-02-09 16:57:54 -03:00
tst-dynarray-shared.h malloc: Sync dynarray with gnulib 2021-02-09 16:57:54 -03:00
tst-dynarray.c Disable -Waggressive-loop-optimizations warnings in tst-dynarray.c 2021-10-29 14:40:45 +00:00
tst-free-errno.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
tst-interpose-aux-nothread.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
tst-interpose-aux-thread.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
tst-interpose-aux.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
tst-interpose-aux.h Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
tst-interpose-nothread.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
tst-interpose-skeleton.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
tst-interpose-static-nothread.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
tst-interpose-static-thread.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
tst-interpose-thread.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
tst-mallinfo2.c tst-mallinfo2.c: Use correct multiple for total variable 2021-05-25 16:47:01 -04:00
tst-malloc_info.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
tst-malloc-backtrace.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
tst-malloc-check.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
tst-malloc-fork-deadlock.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
tst-malloc-stats-cancellation.c malloc: Run tst-malloc-stats-cancellation via test-driver.c 2021-04-07 02:35:50 +02:00
tst-malloc-tcache-leak.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
tst-malloc-thread-exit.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
tst-malloc-thread-fail.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
tst-malloc-too-large.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
tst-malloc-usable-tunables.c Initialize tunable list with the GLIBC_TUNABLES environment variable 2016-12-31 23:49:24 +05:30
tst-malloc-usable.c Handle NULL input to malloc_usable_size [BZ #28506] 2021-10-29 14:53:55 +05:30
tst-malloc.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
tst-mallocalign1.c Add a generic malloc test for MALLOC_ALIGNMENT 2021-07-09 06:39:30 -07:00
tst-mallocfork2.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
tst-mallocfork3.c posix: Add _Fork [BZ #4737] 2021-06-28 15:55:56 -03:00
tst-mallocfork.c Fix malloc tests build with GCC 10. 2019-06-10 22:12:08 +00:00
tst-mallocstate.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
tst-mallopt.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
tst-memalign.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
tst-mtrace.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
tst-mtrace.sh Move malloc hooks into a compat DSO 2021-07-22 18:37:59 +05:30
tst-mxfast.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
tst-obstack.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
tst-posix_memalign.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
tst-pvalloc-fortify.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
tst-pvalloc.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
tst-realloc.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
tst-reallocarray.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
tst-safe-linking.c tst-safe-linking: make false positives even more improbable 2021-07-19 08:29:25 +05:30
tst-scratch_buffer.c malloc: Add scratch_buffer_dupfree 2021-01-05 11:33:16 -03:00
tst-tcfree1.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
tst-tcfree2.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
tst-tcfree3.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
tst-trim1.c * malloc/tst-trim1.c: New file. 2007-12-16 22:57:57 +00:00
tst-valloc.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
Versions Move malloc_{g,s}et_state to libc_malloc_debug 2021-07-22 18:38:10 +05:30