diff mbox series

[PR96608] analyzer: Change cast from long to intptr_t

Message ID CAEZ8vh=cFfGhcgw1L3uJqiPq++zHt_8ZsrX38un6eXvwrLj=vg@mail.gmail.com
State New
Headers show
Series [PR96608] analyzer: Change cast from long to intptr_t | expand

Commit Message

Markus Böck Sept. 30, 2020, 7:43 a.m. UTC
Casting to intptr_t states the intent of an integer to pointer cast
more clearly and ensures that the cast causes no loss of precision on
any platforms. LLP64 platforms eg. have a long value of 4 bytes and
pointer values of 8 bytes which may even cause compiler errors.

Fixes PR 96608

Would need this to be committed for me if accepted. (username
zero9178, email markus.boeck02@gmail.com)

Markus

gcc/analyzer/ChangeLog:
PR analyzer/96608

* store.h (hash): Cast to intptr_t instead of long

---
 gcc/analyzer/store.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

David Malcolm Oct. 27, 2020, 2:06 p.m. UTC | #1
On Wed, 2020-09-30 at 09:43 +0200, Markus Böck wrote:
> Casting to intptr_t states the intent of an integer to pointer cast
> more clearly and ensures that the cast causes no loss of precision on
> any platforms. LLP64 platforms eg. have a long value of 4 bytes and
> pointer values of 8 bytes which may even cause compiler errors.
> 
> Fixes PR 96608
> 
> Would need this to be committed for me if accepted. (username
> zero9178, email markus.boeck02@gmail.com)

Sorry about the long delay on this; I got fixated on seeing if the
approach to how the analyzer hashes things needing changing, to make
the analyzer more deterministic, but I've now fixed the non-determinism 
issue a different way.

The patch looks OK.

Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu.

I've pushed it to master on your behalf as
942086bf73ee2ba6cfd7fdacc552940048437a6e.

Thanks
Dave
diff mbox series

Patch

diff --git a/gcc/analyzer/store.h b/gcc/analyzer/store.h
index 0f4e7ab2a56..9589c566e1b 100644
--- a/gcc/analyzer/store.h
+++ b/gcc/analyzer/store.h
@@ -269,7 +269,7 @@  public:

   hashval_t hash () const
   {
-    return (binding_key::impl_hash () ^ (long)m_region);
+    return (binding_key::impl_hash () ^ (intptr_t)m_region);
   }
   bool operator== (const symbolic_binding &other) const
   {