[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#797151: gcc-4.9: Spurious warnings about pointer to array -> const pointer to array conversion.



Package: gcc-4.9
Version: 4.9.3-3
Severity: normal

Dear Maintainer,

This bug may affect all gcc-4, but has been fixed on gcc-5 upstream:
(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=16602).

When compiling the attached code, gcc-4 always warns
"
ex_ptrtoarr.c: In function ‘main’:
ex_ptrtoarr.c:13:3: warning: passing argument 1 of ‘mdsumcmp’ from
incompatible pointer type [enabled by default]
   return mdsumcmp(&sum1, &sum2);
   ^
ex_ptrtoarr.c:4:5: note: expected ‘const uint8_t (*)[16]’ but argument is
of type ‘uint8_t (*)[16]’
 int mdsumcmp(const uint8_t (*s1)[16], const uint8_t (*s2)[16])
     ^
ex_ptrtoarr.c:13:3: warning: passing argument 2 of ‘mdsumcmp’ from
incompatible pointer type [enabled by default]
   return mdsumcmp(&sum1, &sum2);
   ^
ex_ptrtoarr.c:4:5: note: expected ‘const uint8_t (*)[16]’ but argument is
of type ‘uint8_t (*)[16]’
 int mdsumcmp(const uint8_t (*s1)[16], const uint8_t (*s2)[16])
     ^
"
but gcc-5 and clang complain nothing.



-- System Information:
Debian Release: stretch/sid
  APT prefers testing
  APT policy: (900, 'testing'), (500, 'testing-proposed-updates'), (500, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 4.1.0-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=zh_CN.UTF-8, LC_CTYPE=zh_CN.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages gcc-4.9 depends on:
ii  binutils        2.25.1-1
ii  cpp-4.9         4.9.3-3
ii  gcc-4.9-base    4.9.3-3
ii  libc6           2.19-19
ii  libcloog-isl4   0.18.3-1
ii  libgcc-4.9-dev  4.9.3-3
ii  libgmp10        2:6.0.0+dfsg-7
ii  libisl13        0.14-2
ii  libmpc3         1.0.3-1
ii  libmpfr4        3.1.3-1
ii  zlib1g          1:1.2.8.dfsg-2+b1

Versions of packages gcc-4.9 recommends:
ii  libc6-dev  2.19-19

Versions of packages gcc-4.9 suggests:
pn  gcc-4.9-doc       <none>
pn  gcc-4.9-locales   <none>
pn  gcc-4.9-multilib  <none>
pn  libasan1-dbg      <none>
pn  libatomic1-dbg    <none>
pn  libcilkrts5-dbg   <none>
pn  libgcc1-dbg       <none>
pn  libgomp1-dbg      <none>
pn  libitm1-dbg       <none>
pn  liblsan0-dbg      <none>
pn  libquadmath0-dbg  <none>
pn  libtsan0-dbg      <none>
pn  libubsan0-dbg     <none>

-- no debconf information
#include <string.h>
#include <stdint.h>

int mdsumcmp(const uint8_t (*s1)[16], const uint8_t (*s2)[16])
{
  return memcmp(*s1, *s2, sizeof(*s1));
}

int main(void)
{
  uint8_t sum1[16];
  uint8_t sum2[16];
  return mdsumcmp(&sum1, &sum2);
}

Reply to: