Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1545069
| From | Markus Trippelsdorf <markus@trippelsdorf.de> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [tip:x86/urgent] x86/tools: Fix gcc-7 warning in relocs.c |
| Date | 2016-12-20 13:00 +0100 |
| Message-ID | <sQrfj-56i-3@gated-at.bofh.it> (permalink) |
| References | <sODNE-5R6-11@gated-at.bofh.it> <sQ3PH-6CU-21@gated-at.bofh.it> <sQp3Q-3Nb-45@gated-at.bofh.it> <sQpwR-4cL-1@gated-at.bofh.it> <sQqCB-4RO-1@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On 2016.12.20 at 03:10 -0800, H. Peter Anvin wrote: > On 12/20/16 02:00, Markus Trippelsdorf wrote: > > On 2016.12.20 at 01:30 -0800, H. Peter Anvin wrote: > >> I'd strongly prefer a non-data-dependent solution, specifically adding > >> at the top of sort_relocs(): > >> > >> if (!r->count) > >> return; > >> > >> However, by my reading of the C and POSIX standards, this is a gcc > >> error: qsort() should do nothing if the count is zero. > > > > No, it is invoking undefined behavior. > > > Notice the nonnull attribute in /usr/include/stdlib.h: > > > > 739 /* Sort NMEMB elements of BASE, of SIZE bytes each, > > 740 using COMPAR to perform the comparisons. */ > > 741 extern void qsort (void *__base, size_t __nmemb, size_t __size, > > 742 __compar_fn_t __compar) __nonnull ((1, 4)); > > > > But feel free to revert my patch and add your solution. > > Well, s/gcc/glibc/ then. > > > The qsort() function shall sort an array of nel objects, the > > initial element of which is pointed to by base NULL does not point to any object, therefore it is UB. -- Markus
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH] x86-64: Fix gcc-7 warning in relocs.c Markus Trippelsdorf <markus@trippelsdorf.de> - 2016-12-15 14:00 +0100
[tip:x86/urgent] x86/tools: Fix gcc-7 warning in relocs.c tip-bot for Markus Trippelsdorf <tipbot@zytor.com> - 2016-12-19 12:00 +0100
Re: [tip:x86/urgent] x86/tools: Fix gcc-7 warning in relocs.c "H. Peter Anvin" <hpa@zytor.com> - 2016-12-20 10:40 +0100
Re: [tip:x86/urgent] x86/tools: Fix gcc-7 warning in relocs.c Markus Trippelsdorf <markus@trippelsdorf.de> - 2016-12-20 11:10 +0100
Re: [tip:x86/urgent] x86/tools: Fix gcc-7 warning in relocs.c "H. Peter Anvin" <hpa@zytor.com> - 2016-12-20 12:20 +0100
Re: [tip:x86/urgent] x86/tools: Fix gcc-7 warning in relocs.c Markus Trippelsdorf <markus@trippelsdorf.de> - 2016-12-20 13:00 +0100
Re: [tip:x86/urgent] x86/tools: Fix gcc-7 warning in relocs.c hpa@zytor.com - 2016-12-20 19:40 +0100
Re: [tip:x86/urgent] x86/tools: Fix gcc-7 warning in relocs.c Markus Trippelsdorf <markus@trippelsdorf.de> - 2016-12-20 20:40 +0100
Re: [tip:x86/urgent] x86/tools: Fix gcc-7 warning in relocs.c "H. Peter Anvin" <hpa@zytor.com> - 2016-12-20 22:20 +0100
csiph-web