Skip to content

Commit f1da95c

Browse files
committed
Ignore a build warning in freebsd with gcc-12.
1 parent d2b71ac commit f1da95c

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

freebsd/kern/kern_descrip.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1829,8 +1829,23 @@ fdgrowtable(struct filedesc *fdp, int nfd)
18291829
M_FILEDESC, M_ZERO | M_WAITOK);
18301830
/* copy the old data */
18311831
ntable->fdt_nfiles = nnfiles;
1832+
/*
1833+
* GCC 12+ inlines fdgrowtable into fdinit/fdcopy/fdunshare and its
1834+
* Value Range Propagation (VRP) infers that onfiles could be negative,
1835+
* triggering false-positive -Wstringop-overflow and -Wrestrict warnings.
1836+
* At runtime fd_nfiles is always > 0 (guaranteed by KASSERT above).
1837+
* See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99578
1838+
*/
1839+
#if __GNUC__ >= 12
1840+
#pragma GCC diagnostic push
1841+
#pragma GCC diagnostic ignored "-Wstringop-overflow"
1842+
#pragma GCC diagnostic ignored "-Wrestrict"
1843+
#endif
18321844
memcpy(ntable->fdt_ofiles, otable->fdt_ofiles,
18331845
onfiles * sizeof(ntable->fdt_ofiles[0]));
1846+
#if __GNUC__ >= 12
1847+
#pragma GCC diagnostic pop
1848+
#endif
18341849

18351850
/*
18361851
* Allocate a new map only if the old is not large enough. It will

0 commit comments

Comments
 (0)