[Bug c++/107461] [12 Regression] ambiguity error for friend with templated constexpr argument

2023-03-03 Thread ppalka at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107461

Patrick Palka  changed:

   What|Removed |Added

 CC||headch at gmail dot com

--- Comment #16 from Patrick Palka  ---
*** Bug 109001 has been marked as a duplicate of this bug. ***

[Bug c++/107461] [12 Regression] ambiguity error for friend with templated constexpr argument

2023-02-06 Thread ppalka at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107461

Patrick Palka  changed:

   What|Removed |Added

 Status|REOPENED|RESOLVED
 Resolution|--- |FIXED

--- Comment #15 from Patrick Palka  ---
Fixed, hopefully

[Bug c++/107461] [12 Regression] ambiguity error for friend with templated constexpr argument

2023-02-06 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107461

--- Comment #14 from CVS Commits  ---
The releases/gcc-12 branch has been updated by Patrick Palka
:

https://gcc.gnu.org/g:eda24f6c12b6d3777ff3bf3656187e695a3e8dc2

commit r12-9110-geda24f6c12b6d3777ff3bf3656187e695a3e8dc2
Author: Patrick Palka 
Date:   Sun Feb 5 21:35:33 2023 -0500

c++: equivalence of non-dependent calls [PR107461]

After r13-5684-g59e0376f607805 the (pruned) callee of a non-dependent
CALL_EXPR is a bare FUNCTION_DECL rather than ADDR_EXPR of FUNCTION_DECL.
This innocent change revealed that cp_tree_equal doesn't first check
dependence of a CALL_EXPR before treating a FUNCTION_DECL callee as a
dependent name, which leads to us incorrectly accepting the first two
testcases below and rejecting the third:

 * In the first testcase, cp_tree_equal incorrectly returns true for
   the two non-dependent CALL_EXPRs f(0) and f(0) (whose CALL_EXPR_FN
   are different FUNCTION_DECLs) which causes us to treat #2 as a
   redeclaration of #1.

 * Same issue in the second testcase, for f() and f().

 * In the third testcase, cp_tree_equal incorrectly returns true for
   f() and f() which causes us to conflate the two
   dependent specializations A()(U()))> and
   A()(U()))>.

This patch fixes this by making called_fns_equal treat two callees as
dependent names only if the overall CALL_EXPRs are dependent, via a new
convenience function call_expr_dependent_name that is like dependent_name
but also checks dependence of the overall CALL_EXPR.

PR c++/107461

gcc/cp/ChangeLog:

* cp-tree.h (call_expr_dependent_name): Declare.
* pt.cc (iterative_hash_template_arg) : Use
call_expr_dependent_name instead of dependent_name.
* tree.cc (call_expr_dependent_name): Define.
(called_fns_equal): Adjust to take two CALL_EXPRs instead of
CALL_EXPR_FNs thereof.  Use call_expr_dependent_name instead
of dependent_name.
(cp_tree_equal) : Adjust call to called_fns_equal.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/overload5.C: New test.
* g++.dg/cpp0x/overload5a.C: New test.
* g++.dg/cpp0x/overload6.C: New test.

(cherry picked from commit 31924665c86d47af6b1f22a74f594f2e1dc0ed2d)

[Bug c++/107461] [12 Regression] ambiguity error for friend with templated constexpr argument

2023-02-04 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107461

Jakub Jelinek  changed:

   What|Removed |Added

 Resolution|FIXED   |---
 Status|RESOLVED|REOPENED

--- Comment #8 from Jakub Jelinek  ---
.

[Bug c++/107461] [12 Regression] ambiguity error for friend with templated constexpr argument

2023-02-04 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107461

Jakub Jelinek  changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org

--- Comment #7 from Jakub Jelinek  ---
Reduced testcase:
template  T foo ();
template  using A = int;
template 
auto operator| (T, U) -> decltype (U() (T()));
template  struct B {
  template  () (0, foo
()))>>
  void operator() (U);
};
struct {
  template 
  B operator() (T, U) { return B (); }
} c;
struct D {
  D() {
c([] {}, 0);
  }
  struct E {
  };
  void bar ()
  {
E f;
f | c ([] (int, E) {}, 0);
  }
};

[Bug c++/107461] [12 Regression] ambiguity error for friend with templated constexpr argument

2023-02-03 Thread raj.khem at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107461

Khem Raj  changed:

   What|Removed |Added

 CC||raj.khem at gmail dot com

--- Comment #6 from Khem Raj  ---
This is now resulting in build error in harfbuzz on aarch64 which did not
happen before, the testcase is here

https://uclibc.org/~kraj/hb-aat-layout.cc.i

Compile cmd used is

/mnt/b/cross/aarch64-linux-musl/tools/bin/aarch64-linux-musl-g++
--sysroot=/mnt/b/yoe/master/build/tmp/work/cortexa72-yoe-linux/harfbuzz/6.0.0-r0/recipe-sysroot
-fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security
-Werror=format-security -Isrc/libharfbuzz.so.0.60600.0.p -Isrc
-I../harfbuzz-6.0.0/src -I. -I../harfbuzz-6.0.0 -fdiagnostics-color=always
-D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -std=c++11 -fno-rtti -fno-exceptions
-fno-rtti -fno-threadsafe-statics -fvisibility-inlines-hidden -DHAVE_CONFIG_H
-O2 -pipe -g -feliminate-unused-debug-types
-fmacro-prefix-map=/mnt/b/yoe/master/build/tmp/work/cortexa72-yoe-linux/harfbuzz/6.0.0-r0/harfbuzz-6.0.0=/usr/src/debug/harfbuzz/6.0.0-r0
-fdebug-prefix-map=/mnt/b/yoe/master/build/tmp/work/cortexa72-yoe-linux/harfbuzz/6.0.0-r0/harfbuzz-6.0.0=/usr/src/debug/harfbuzz/6.0.0-r0
-fmacro-prefix-map=/mnt/b/yoe/master/build/tmp/work/cortexa72-yoe-linux/harfbuzz/6.0.0-r0/build=/usr/src/debug/harfbuzz/6.0.0-r0
-fdebug-prefix-map=/mnt/b/yoe/master/build/tmp/work/cortexa72-yoe-linux/harfbuzz/6.0.0-r0/build=/usr/src/debug/harfbuzz/6.0.0-r0
-fdebug-prefix-map=/mnt/b/yoe/master/build/tmp/work/cortexa72-yoe-linux/harfbuzz/6.0.0-r0/recipe-sysroot=
-fmacro-prefix-map=/mnt/b/yoe/master/build/tmp/work/cortexa72-yoe-linux/harfbuzz/6.0.0-r0/recipe-sysroot=
-fdebug-prefix-map=/mnt/b/yoe/master/build/tmp/work/cortexa72-yoe-linux/harfbuzz/6.0.0-r0/recipe-sysroot-native=
-fvisibility-inlines-hidden -fPIC -pthread -Wno-non-virtual-dtor -MD -MQ
src/libharfbuzz.so.0.60600.0.p/hb-aat-layout.cc.o -MF
src/libharfbuzz.so.0.60600.0.p/hb-aat-layout.cc.o.d -o
src/libharfbuzz.so.0.60600.0.p/hb-aat-layout.cc.o -c
../harfbuzz-6.0.0/src/hb-aat-layout.cc

[Bug c++/107461] [12 Regression] ambiguity error for friend with templated constexpr argument

2023-02-03 Thread ppalka at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107461

Patrick Palka  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #5 from Patrick Palka  ---
Fixed for GCC 12.3/13, thanks for the bug report.

[Bug c++/107461] [12 Regression] ambiguity error for friend with templated constexpr argument

2023-02-03 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107461

--- Comment #4 from CVS Commits  ---
The releases/gcc-12 branch has been updated by Patrick Palka
:

https://gcc.gnu.org/g:534aea1ca7e7538dc6af3eac3cd2ec6c7343fdee

commit r12-9103-g534aea1ca7e7538dc6af3eac3cd2ec6c7343fdee
Author: Patrick Palka 
Date:   Fri Feb 3 09:41:10 2023 -0500

c++: unexpected ADDR_EXPR after overload set pruning [PR107461]

Here the ahead-of-time overload set pruning in finish_call_expr is
unintentionally returning a CALL_EXPR whose (pruned) callee is wrapped
in an ADDR_EXPR, despite the original callee not being wrapped in an
ADDR_EXPR.  This ends up causing a bogus declaration mismatch error in
the below testcase because the call to min in #1 gets expressed as a
CALL_EXPR of ADDR_EXPR of FUNCTION_DECL, whereas the level-lowered call
to min in #2 gets expressed instead as a CALL_EXPR of FUNCTION_DECL.

This patch fixes this by stripping the spurious ADDR_EXPR appropriately.
Thus the first call to min now also gets expressed as a CALL_EXPR of
FUNCTION_DECL, matching the behavior before r12-6075-g2decd2cabe5a4f.

PR c++/107461

gcc/cp/ChangeLog:

* semantics.cc (finish_call_expr): Strip ADDR_EXPR from
the selected callee during overload set pruning.

gcc/testsuite/ChangeLog:

* g++.dg/template/call9.C: New test.

(cherry picked from commit 59e0376f607805ef9b67fd7b0a4a3084ab3571a5)