public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/12672] Evals template defaults args that it should not
       [not found] <bug-12672-4@http.gcc.gnu.org/bugzilla/>
@ 2021-08-25 20:49 ` ppalka at gcc dot gnu.org
  2021-08-31 17:31 ` cvs-commit at gcc dot gnu.org
  2021-09-13 15:09 ` ppalka at gcc dot gnu.org
  2 siblings, 0 replies; 9+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-08-25 20:49 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=12672

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |ppalka at gcc dot gnu.org
                 CC|                            |ppalka at gcc dot gnu.org

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/12672] Evals template defaults args that it should not
       [not found] <bug-12672-4@http.gcc.gnu.org/bugzilla/>
  2021-08-25 20:49 ` [Bug c++/12672] Evals template defaults args that it should not ppalka at gcc dot gnu.org
@ 2021-08-31 17:31 ` cvs-commit at gcc dot gnu.org
  2021-09-13 15:09 ` ppalka at gcc dot gnu.org
  2 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-08-31 17:31 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=12672

--- Comment #15 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:

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

commit r12-3271-gf1e7319956928712e8bf4893ebdfeeb6441099ee
Author: Patrick Palka <ppalka@redhat.com>
Date:   Tue Aug 31 13:31:10 2021 -0400

    c++: check arity before deduction w/ explicit targs [PR12672]

    During overload resolution, when the arity of a function template
    clearly disagrees with the arity of the call, no specialization of the
    function template could yield a viable candidate.  The deduction routine
    type_unification_real already notices this situation, but not before
    it substitutes explicit template arguments into the template, a step
    which could induce a hard error.  Although it's necessary to perform
    this substitution first in order to check arity perfectly (since the
    substitution can e.g. expand a non-trailing parameter pack), in most
    cases we can determine ahead of time whether there's an arity
    disagreement without needing to perform deduction at all.

    To that end, this patch implements an (approximate) arity check in
    add_template_candidate_real that guards actual deduction.  It's enabled
    only when there are explicit template arguments since that's when
    deduction can force otherwise avoidable template instantiations.  (I
    experimented with enabling it unconditionally as an optimization, and
    observed some improvements to compile time of about 5% but also some
    slowdowns of about the same magnitude, so kept it conditional.)

    In passing, this adds a least_p parameter to arity_rejection for sake
    of consistent diagnostics with unify_arity.

    A couple of testcases needed to be adjusted so that deduction continues
    to occur as intended after this change.  Except in unify6.C, where we
    were expecting foo<void ()> to be ill-formed due to substitution
    forming a function type with an added 'const', but ISTM this is
    permitted by [dcl.fct]/7, so I changed the test accordingly.

            PR c++/12672

    gcc/cp/ChangeLog:

            * call.c (rejection_reason::call_varargs_p): Rename this
            previously unused member to ...
            (rejection_reason::least_p): ... this.
            (arity_rejection): Add least_p parameter.
            (add_template_candidate_real): When there are explicit
            template arguments, check that the arity of the call agrees with
            the arity of the function before attempting deduction.
            (print_arity_information): Add least_p parameter.
            (print_z_candidate): Adjust call to print_arity_information.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp0x/decltype29.C: Adjust.
            * g++.dg/template/error56.C: Adjust.
            * g++.old-deja/g++.pt/unify6.C: Adjust.
            * g++.dg/template/explicit-args7.C: New test.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/12672] Evals template defaults args that it should not
       [not found] <bug-12672-4@http.gcc.gnu.org/bugzilla/>
  2021-08-25 20:49 ` [Bug c++/12672] Evals template defaults args that it should not ppalka at gcc dot gnu.org
  2021-08-31 17:31 ` cvs-commit at gcc dot gnu.org
@ 2021-09-13 15:09 ` ppalka at gcc dot gnu.org
  2 siblings, 0 replies; 9+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-09-13 15:09 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=12672

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |12.0
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #16 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 12 by accepting such code, which is permitted but not required by
the standard.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/12672] Evals template defaults args that it should not
       [not found] <bug-12672-6594@http.gcc.gnu.org/bugzilla/>
@ 2009-04-16 17:02 ` igodard at pacbell dot net
  0 siblings, 0 replies; 9+ messages in thread
From: igodard at pacbell dot net @ 2009-04-16 17:02 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from igodard at pacbell dot net  2009-04-16 17:02 -------
Wow! Six years and counting! This might be my oldest outstanding bug.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12672


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/12672] Evals template defaults args that it should not
  2003-10-18  8:24 [Bug c++/12672] New: " igodard at pacbell dot net
                   ` (3 preceding siblings ...)
  2003-10-18 19:50 ` bangerth at dealii dot org
@ 2003-12-28 22:13 ` pinskia at gcc dot gnu dot org
  4 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-12-28 22:13 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
   Last reconfirmed|2003-10-18 19:47:24         |2003-12-28 21:40:24
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12672


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/12672] Evals template defaults args that it should not
  2003-10-18  8:24 [Bug c++/12672] New: " igodard at pacbell dot net
                   ` (2 preceding siblings ...)
  2003-10-18 16:19 ` pinskia at gcc dot gnu dot org
@ 2003-10-18 19:50 ` bangerth at dealii dot org
  2003-12-28 22:13 ` pinskia at gcc dot gnu dot org
  4 siblings, 0 replies; 9+ messages in thread
From: bangerth at dealii dot org @ 2003-10-18 19:50 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12672


bangerth at dealii dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2003-10-18 19:47:24
               date|                            |


------- Additional Comments From bangerth at dealii dot org  2003-10-18 19:47 -------
Confirmed. Here's something even shorter:
---------------------------
template <typename T> struct S {
    typedef typename T::type type;
};

template<typename U, typename V = typename S<U>::type>
struct A {};

template<typename T> A<T> Foo(T);
template<typename T> void Foo(T, T);

int main() {
  Foo<int>(1, 2);
}
----------------------------
This fails to compile because the compiler tries to instantiate
the return type of the first Foo function. Whether that is actually
taken is irrelevant here, since we are only doing name lookup at this
stage, but we shouldn't error out: this is a SFINAE failure and
should just remove the first Foo function from the list of candidates.
It shouldn't be an error.

I confirm this for 3.3 and 3.4 builds from 2003-09-19, since this is
the latest I presently have. They both say
g/x> /home/bangerth/bin/gcc-3.4-pre/bin/c++ -c x.cc
x.cc: In instantiation of `S<int>':
x.cc:12:   instantiated from here
x.cc:2: error: `int' is not a class, struct, or union type

What startles me a bit is that icc7 also shows the error. I am pretty sure,
though, that this is in error as well.

W.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/12672] Evals template defaults args that it should not
  2003-10-18  8:24 [Bug c++/12672] New: " igodard at pacbell dot net
  2003-10-18  8:26 ` [Bug c++/12672] " igodard at pacbell dot net
  2003-10-18 11:28 ` igodard at pacbell dot net
@ 2003-10-18 16:19 ` pinskia at gcc dot gnu dot org
  2003-10-18 19:50 ` bangerth at dealii dot org
  2003-12-28 22:13 ` pinskia at gcc dot gnu dot org
  4 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-10-18 16:19 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12672



------- Additional Comments From pinskia at gcc dot gnu dot org  2003-10-18 15:46 -------
Here is the example without an extra includes, I have not looked to see what the standard says 
abou this though:
template<typename i> class it
{
        typedef typename i::iterator_category iterator_category;
};

template<typename U>
class UT { public: U u;};

template<typename U,
                        typename C = typename it<U>::iterator_category>
class Aux {
public:
        typedef UT<U> R;
        };


template<typename T> class R { public: T t;};

template<typename T>
typename Aux<T>::R Foo(T t) { return 0; }

template<typename T>
void Foo(T, T);

void Foo(int, int) { }

template<typename T>
T Bar(T, T);

inline int Bar(int i1, int i2) { return i1; }
inline char Bar(char c1, char c2) { return c1; }

int main() {
        Bar(0, 1);
        Bar<char>(0, 1);
        Bar<int>(0, 1);
        Foo(1, 2);
        Foo<int>(1, 2);
        }


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/12672] Evals template defaults args that it should not
  2003-10-18  8:24 [Bug c++/12672] New: " igodard at pacbell dot net
  2003-10-18  8:26 ` [Bug c++/12672] " igodard at pacbell dot net
@ 2003-10-18 11:28 ` igodard at pacbell dot net
  2003-10-18 16:19 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: igodard at pacbell dot net @ 2003-10-18 11:28 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12672



------- Additional Comments From igodard at pacbell dot net  2003-10-18 08:26 -------
Created an attachment (id=4957)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=4957&action=view)
Source code (-save-temps)


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/12672] Evals template defaults args that it should not
  2003-10-18  8:24 [Bug c++/12672] New: " igodard at pacbell dot net
@ 2003-10-18  8:26 ` igodard at pacbell dot net
  2003-10-18 11:28 ` igodard at pacbell dot net
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: igodard at pacbell dot net @ 2003-10-18  8:26 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12672



------- Additional Comments From igodard at pacbell dot net  2003-10-18 08:24 -------
Created an attachment (id=4956)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=4956&action=view)
Compiler output (-v -save-temps)


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-09-13 15:09 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-12672-4@http.gcc.gnu.org/bugzilla/>
2021-08-25 20:49 ` [Bug c++/12672] Evals template defaults args that it should not ppalka at gcc dot gnu.org
2021-08-31 17:31 ` cvs-commit at gcc dot gnu.org
2021-09-13 15:09 ` ppalka at gcc dot gnu.org
     [not found] <bug-12672-6594@http.gcc.gnu.org/bugzilla/>
2009-04-16 17:02 ` igodard at pacbell dot net
2003-10-18  8:24 [Bug c++/12672] New: " igodard at pacbell dot net
2003-10-18  8:26 ` [Bug c++/12672] " igodard at pacbell dot net
2003-10-18 11:28 ` igodard at pacbell dot net
2003-10-18 16:19 ` pinskia at gcc dot gnu dot org
2003-10-18 19:50 ` bangerth at dealii dot org
2003-12-28 22:13 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).