From: Jason Merrill Date: Fri, 25 May 2018 16:44:55 +0000 (-0400) Subject: PR c++/80485 - inline function non-zero address. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f22ed1ed2ae240124d5a5a0b8fa2cb1fc7d62e00;p=gcc.git PR c++/80485 - inline function non-zero address. * symtab.c (nonzero_address): Check DECL_COMDAT. From-SVN: r260762 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 04b94ff9ad6..a1ef11eecac 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2018-05-25 Jason Merrill + + PR c++/80485 - inline function non-zero address. + * symtab.c (nonzero_address): Check DECL_COMDAT. + 2018-05-25 Uros Bizjak PR target/83628 diff --git a/gcc/symtab.c b/gcc/symtab.c index 954920b6dff..67e14d76b11 100644 --- a/gcc/symtab.c +++ b/gcc/symtab.c @@ -1959,11 +1959,11 @@ symtab_node::nonzero_address () return true; } - /* If target is defined and not extern, we know it will be output and thus - it will bind to non-NULL. - Play safe for flag_delete_null_pointer_checks where weak definition maye + /* If target is defined and either comdat or not extern, we know it will be + output and thus it will bind to non-NULL. + Play safe for flag_delete_null_pointer_checks where weak definition may be re-defined by NULL. */ - if (definition && !DECL_EXTERNAL (decl) + if (definition && (!DECL_EXTERNAL (decl) || DECL_COMDAT (decl)) && (flag_delete_null_pointer_checks || !DECL_WEAK (decl))) { if (!DECL_WEAK (decl)) diff --git a/gcc/testsuite/g++.dg/expr/pmf-3.C b/gcc/testsuite/g++.dg/expr/pmf-3.C new file mode 100644 index 00000000000..fac42fc23a5 --- /dev/null +++ b/gcc/testsuite/g++.dg/expr/pmf-3.C @@ -0,0 +1,15 @@ +// PR c++/80485 +// { dg-do compile { target c++11 } } + +struct dummy { + void nonnull() {}; + void nonnull2(); +}; + +typedef void (dummy::*safe_bool)(); + +constexpr safe_bool a = &dummy::nonnull; +constexpr safe_bool b = &dummy::nonnull2; + +static_assert( static_cast( a ), "" ); +static_assert( static_cast( b ), "" );