public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug analyzer/102052] New: analyser testsuite failures with LLP64 model
@ 2021-08-25  2:17 nightstrike at gmail dot com
  2022-02-10 14:14 ` [Bug analyzer/102052] " cvs-commit at gcc dot gnu.org
  2022-02-10 14:17 ` dmalcolm at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: nightstrike at gmail dot com @ 2021-08-25  2:17 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102052

            Bug ID: 102052
           Summary: analyser testsuite failures with LLP64 model
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: analyzer
          Assignee: dmalcolm at gcc dot gnu.org
          Reporter: nightstrike at gmail dot com
  Target Milestone: ---

Additional details here:
https://gcc.gnu.org/pipermail/gcc/2021-August/237158.html

pr98969.c:9:19: warning: cast to pointer from integer of different size
[-Wint-to-pointer-cast]
* This fails because the function arguments are "long int", and that tries to
hold a pointer.  It should be uintptr_t or similar.

Something like this should work:

diff --git a/gcc/testsuite/gcc.dg/analyzer/pr98969.c
b/gcc/testsuite/gcc.dg/analyzer/pr98969.c
index 7e1587d..770e6d2 100644
--- a/gcc/testsuite/gcc.dg/analyzer/pr98969.c
+++ b/gcc/testsuite/gcc.dg/analyzer/pr98969.c
@@ -4,14 +4,14 @@ struct foo
 };

 void
-test_1 (long int i)
+test_1 (__UINTPTR_TYPE__ i)
 {
   struct foo *f = (struct foo *)i;
   f->expr = __builtin_malloc (1024);
 } /* { dg-bogus "leak" } */

 void
-test_2 (long int i)
+test_2 (__UINTPTR_TYPR__ i)
 {
   __builtin_free (((struct foo *)i)->expr);
   __builtin_free (((struct foo *)i)->expr); /* { dg-warning "double-'free' of
'\\*\\(\\(struct foo \\*\\)i\\)\\.expr'" } */



pr99716-2.c:13:30: warning: implicit declaration of function 'random';did you
mean 'rand'? [-Wimplicit-function-declaration]
* The C function is rand(), so it's not clear to me at least why the code is
using random.  I have no idea what the test is testing, so I don't know if
rand() is a drop in replacement, but here you go:

index 7c9881c..adc9819 100644
--- a/gcc/testsuite/gcc.dg/analyzer/pr99716-2.c
+++ b/gcc/testsuite/gcc.dg/analyzer/pr99716-2.c
@@ -10,7 +10,7 @@ extern int foo (void);
 void
 test_mountpoint (const char *mp)
 {
-  const int nr_passes = 5 + (random () & 31);
+  const int nr_passes = 5 + (rand () & 31);
   int pass;
   int ret = 1;
   FILE *fp;



pr99774-1.c:12:14: warning: conflicting types for built-in function 'calloc';
expected 'void *(long long unsigned int,  long long unsigned int)'
[-Wbuiltin-declaration-mismatch]
zlib-5.c:10:15: warning: conflicting types for built-in function 'strlen';
expected 'long long unsigned int(const char *)'
[-Wbuiltin-declaration-mismatch]
zlib-5.c:16:14: warning: conflicting types for built-in function 'calloc';
expected 'void *(long long unsigned int,  long long unsigned int)'
[-Wbuiltin-declaration-mismatch]
* These are all examples of hardcoding a size_t typedef that is incorrect for
an LLP64 model.  Something like this would probably be enough to fix it:

diff --git a/gcc/testsuite/gcc.dg/analyzer/pr99774-1.c
b/gcc/testsuite/gcc.dg/analyzer/pr99774-1.c
index 620cf65..a2138d9 100644
--- a/gcc/testsuite/gcc.dg/analyzer/pr99774-1.c
+++ b/gcc/testsuite/gcc.dg/analyzer/pr99774-1.c
@@ -7,9 +7,8 @@ typedef unsigned char uint8_t;
 typedef unsigned short uint16_t;
 typedef unsigned long uint64_t;
 typedef unsigned long uint64_t;
-typedef long unsigned int size_t;

-extern void *calloc(size_t __nmemb, size_t __size)
+extern void *calloc(__SIZE_TYPE__ __nmemb, __SIZE_TYPE__ __size)
   __attribute__((__nothrow__, __leaf__))
   __attribute__((__malloc__))
   __attribute__((__alloc_size__(1, 2)))
diff --git a/gcc/testsuite/gcc.dg/analyzer/zlib-5.c
b/gcc/testsuite/gcc.dg/analyzer/zlib-5.c
index afb6102..93df2b1 100644
--- a/gcc/testsuite/gcc.dg/analyzer/zlib-5.c
+++ b/gcc/testsuite/gcc.dg/analyzer/zlib-5.c
@@ -2,18 +2,17 @@

 #include "analyzer-decls.h"

-typedef long unsigned int size_t;
 typedef unsigned char Byte;
 typedef unsigned int uInt;
 typedef unsigned long uLong;

-extern size_t strlen(const char *__s) __attribute__((__nothrow__, __leaf__))
+extern __SIZE_TYPE__ strlen(const char *__s) __attribute__((__nothrow__,
__leaf__))
     __attribute__((__pure__)) __attribute__((__nonnull__(1)));
 extern void exit(int __status) __attribute__((__nothrow__, __leaf__))
     __attribute__((__noreturn__));
 extern char *strcpy(char *__restrict __dest, const char *__restrict __src)
     __attribute__((__nothrow__, __leaf__)) __attribute__((__nonnull__(1, 2)));
-extern void *calloc(size_t __nmemb, size_t __size)
+extern void *calloc(__SIZE_TYPE__ __nmemb, __SIZE_TYPE__ __size)
     __attribute__((__nothrow__, __leaf__)) __attribute__((__malloc__));

 extern int compress(Byte *dest, uLong *destLen, const Byte *source,



strndup-1.c:9:13: warning: incompatible implicit declaration of built-in
function 'strndup' [-Wbuiltin-declaration-mismatch]
* This function doesn't exist on windows.  So, either we add it to libmingwex
if it isn't already there and then link that library in to
the test, or just mark it as unsupported.  I'd probably prefer the former, but
it's not up to me.  Let me know what I should do here.


gcc.dg/analyzer/gzio-3.c:
gcc.dg/analyzer/gzio-3a.c:
* For some reason, these work.  Maybe fread() isn't a builtin? Maybe
there's a way to make gcc emit a warning when fread() is redefined
differently.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug analyzer/102052] analyser testsuite failures with LLP64 model
  2021-08-25  2:17 [Bug analyzer/102052] New: analyser testsuite failures with LLP64 model nightstrike at gmail dot com
@ 2022-02-10 14:14 ` cvs-commit at gcc dot gnu.org
  2022-02-10 14:17 ` dmalcolm at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-02-10 14:14 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102052

--- Comment #1 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by David Malcolm <dmalcolm@gcc.gnu.org>:

https://gcc.gnu.org/g:8383d41d704571d7ca234c7d2f551b7b69255194

commit r12-7180-g8383d41d704571d7ca234c7d2f551b7b69255194
Author: David Malcolm <dmalcolm@redhat.com>
Date:   Wed Feb 9 17:55:55 2022 -0500

    analyzer: fix testsuite issues seen with mingw [PR102052]

    gcc/testsuite/ChangeLog:
            PR analyzer/102052
            * gcc.dg/analyzer/fields.c (size_t): Use __SIZE_TYPE__ rather than
            hardcoding long unsigned int.
            * gcc.dg/analyzer/gzio-3.c (size_t): Likewise.
            * gcc.dg/analyzer/gzio-3a.c (size_t): Likewise.
            * gcc.dg/analyzer/pr98969.c (test_1): Use __UINTPTR_TYPE__ rather
            than long int.
            (test_2): Likewise.
            * gcc.dg/analyzer/pr99716-2.c (test_mountpoint): Use "rand" rather
            than "random".
            * gcc.dg/analyzer/pr99774-1.c (size_t): Use __SIZE_TYPE__ rather
            than hardcoding long unsigned int.
            * gcc.dg/analyzer/strndup-1.c: Add MinGW to targets that don't
            implement strndup.
            * gcc.dg/analyzer/zlib-5.c (size_t): Use __SIZE_TYPE__ rather
            than hardcoding long unsigned int.

    Signed-off-by: David Malcolm <dmalcolm@redhat.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug analyzer/102052] analyser testsuite failures with LLP64 model
  2021-08-25  2:17 [Bug analyzer/102052] New: analyser testsuite failures with LLP64 model nightstrike at gmail dot com
  2022-02-10 14:14 ` [Bug analyzer/102052] " cvs-commit at gcc dot gnu.org
@ 2022-02-10 14:17 ` dmalcolm at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2022-02-10 14:17 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102052

David Malcolm <dmalcolm at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #2 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
Thanks for filing this bug.  Hopefully the above patch fixes things, so I'm
marking this bug as resolved.  Please reopen it if there are any remaining
issues.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-02-10 14:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-25  2:17 [Bug analyzer/102052] New: analyser testsuite failures with LLP64 model nightstrike at gmail dot com
2022-02-10 14:14 ` [Bug analyzer/102052] " cvs-commit at gcc dot gnu.org
2022-02-10 14:17 ` dmalcolm at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).