From: Jakub Jelinek Date: Thu, 9 Dec 2021 14:54:33 +0000 (+0100) Subject: pch: Fix up Darwin and HPUX pch_use_address hooks [PR71934] X-Git-Tag: basepoints/gcc-13~2457 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bf15cd665e74791aae87e7e151a0cf0c4cb54684;p=thirdparty%2Fgcc.git pch: Fix up Darwin and HPUX pch_use_address hooks [PR71934] In the last change, I've changed the arguments from void * to void *&, but missed the fact that these hooks will in that case update the value the caller will see in an undesirable way. 2021-12-09 Jakub Jelinek PR pch/71934 * config/host-darwin.c (darwin_gt_pch_use_address): When reading manually the file into mapped area, update mapped_addr as an automatic variable rather than addr which is a reference parameter. * config/host-hpux.c (hpux_gt_pch_use_address): When reading manually the file into mapped area, update addr as an automatic variable rather than base which is a reference parameter. --- diff --git a/gcc/config/host-darwin.c b/gcc/config/host-darwin.c index d3c2858c9975..403cd38a2481 100644 --- a/gcc/config/host-darwin.c +++ b/gcc/config/host-darwin.c @@ -185,10 +185,10 @@ darwin_gt_pch_use_address (void *&addr, size_t sz, int fd, size_t off) { ssize_t nbytes; - nbytes = read (fd, addr, MIN (sz, (size_t) -1 >> 1)); + nbytes = read (fd, mapped_addr, MIN (sz, (size_t) -1 >> 1)); if (nbytes <= 0) return -1; - addr = (char *) addr + nbytes; + mapped_addr = (char *) mapped_addr + nbytes; sz -= nbytes; } diff --git a/gcc/config/host-hpux.c b/gcc/config/host-hpux.c index 796f501ebfb6..c63dda89344e 100644 --- a/gcc/config/host-hpux.c +++ b/gcc/config/host-hpux.c @@ -115,10 +115,10 @@ hpux_gt_pch_use_address (void *&base, size_t size, int fd, size_t offset) { ssize_t nbytes; - nbytes = read (fd, base, MIN (size, SSIZE_MAX)); + nbytes = read (fd, addr, MIN (size, SSIZE_MAX)); if (nbytes <= 0) return -1; - base = (char *) base + nbytes; + addr = (char *) addr + nbytes; size -= nbytes; }