diff mbox series

[COMMITTED] libstdc++: Avoid using sizeof with function types (PR 93470)

Message ID 20200128133121.GA53656@redhat.com
State New
Headers show
Series [COMMITTED] libstdc++: Avoid using sizeof with function types (PR 93470) | expand

Commit Message

Jonathan Wakely Jan. 28, 2020, 1:31 p.m. UTC
PR libstdc++/93470
	* include/bits/refwrap.h (reference_wrapper::operator()): Restrict
	static assertion to object types.

Tested powerpc64le-linux and verified with Clang.

Committed to master. Backport to gcc-9-branch needed too.
commit 72a9fd209b6db3b5f81fbb008e22ea93c00465e5
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Jan 28 13:24:09 2020 +0000

    libstdc++: Avoid using sizeof with function types (PR 93470)
    
            PR libstdc++/93470
            * include/bits/refwrap.h (reference_wrapper::operator()): Restrict
            static assertion to object types.
diff mbox series

Patch

diff --git a/libstdc++-v3/include/bits/refwrap.h b/libstdc++-v3/include/bits/refwrap.h
index 2bcd44d3894..717aa01629c 100644
--- a/libstdc++-v3/include/bits/refwrap.h
+++ b/libstdc++-v3/include/bits/refwrap.h
@@ -343,7 +343,8 @@  _GLIBCXX_MEM_FN_TRAITS(&& noexcept, false_type, true_type)
 	operator()(_Args&&... __args) const
 	{
 #if __cplusplus > 201703L
-	  static_assert(sizeof(type), "type must be complete");
+	  if constexpr (is_object_v<type>)
+	    static_assert(sizeof(type), "type must be complete");
 #endif
 	  return std::__invoke(get(), std::forward<_Args>(__args)...);
 	}