This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] analyzer: fix build error with clang (PR 93543)


On Tue, 2020-02-04 at 14:53 +0100, Sebastian Huber wrote:
> Hello,
> 
> I tried to build a recent GCC master on FreeBSD 12.1 and it failed
> with 
> a compile error:
> 
> $ clang --version
> FreeBSD clang version 8.0.1 (tags/RELEASE_801/final 366581) (based
> on 
> LLVM 8.0.1)
> Target: x86_64-unknown-freebsd12.1
> Thread model: posix
> InstalledDir: /usr/bin
> 
> ../../gnu-mirror-gcc-5bc9d2f5ed4/gcc/analyzer/engine.cc:2965:13:
> error: 
> reinterpret_cast from 'nullptr_t' to 'function *' is not allowed
>    v.m_fun = reinterpret_cast<function *> (NULL);
>              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ../../gnu-mirror-gcc-5bc9d2f5ed4/gcc/analyzer/engine.cc:2977:21:
> error: 
> reinterpret_cast from 'nullptr_t' to 'function *' is not allowed
>    return v.m_fun == reinterpret_cast<function *> (NULL);
>                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> This simple test program fails also:
> 
> struct function;
> 
> function *f(void)
> {
>    return reinterpret_cast<function *>(nullptr);
> }
> 
> $ clang -c test.cc
> test.cc:5:10: error: reinterpret_cast from 'nullptr_t' to 'function
> *' 
> is not allowed
>    return reinterpret_cast<function *>(nullptr);
>           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 1 error generated.
> 
> I was able to build the GCC master on January 2nd 2020. Does this
> look 
> like an LLVM 8.0.1 issue or a GCC issue?

Sorry, this was my code.

This is https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93543

Does this patch fix the build for you with clang?

gcc/analyzer/ChangeLog:
	PR analyzer/93543
	* engine.cc (pod_hash_traits<function_call_string>::mark_empty):
	Eliminate reinterpret_cast.
	(pod_hash_traits<function_call_string>::is_empty): Likewise.
---
 gcc/analyzer/engine.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/analyzer/engine.cc b/gcc/analyzer/engine.cc
index 90f7067dec1..81b8a76c5eb 100644
--- a/gcc/analyzer/engine.cc
+++ b/gcc/analyzer/engine.cc
@@ -2962,7 +2962,7 @@ template <>
 inline void
 pod_hash_traits<function_call_string>::mark_empty (value_type &v)
 {
-  v.m_fun = reinterpret_cast<function *> (NULL);
+  v.m_fun = NULL;
 }
 template <>
 inline bool
@@ -2974,7 +2974,7 @@ template <>
 inline bool
 pod_hash_traits<function_call_string>::is_empty (value_type v)
 {
-  return v.m_fun == reinterpret_cast<function *> (NULL);
+  return v.m_fun == NULL;
 }
 
 namespace ana {
-- 
2.21.0


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]