public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/38174] Missing some built-in candidates for operator overloading
       [not found] <bug-38174-4@http.gcc.gnu.org/bugzilla/>
@ 2011-10-12 21:38 ` paolo.carlini at oracle dot com
  2011-10-12 21:41 ` paolo.carlini at oracle dot com
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 10+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-10-12 21:38 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrew.stubbs at st dot com

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-10-12 21:37:54 UTC ---
*** Bug 29148 has been marked as a duplicate of this bug. ***


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

* [Bug c++/38174] Missing some built-in candidates for operator overloading
       [not found] <bug-38174-4@http.gcc.gnu.org/bugzilla/>
  2011-10-12 21:38 ` [Bug c++/38174] Missing some built-in candidates for operator overloading paolo.carlini at oracle dot com
@ 2011-10-12 21:41 ` paolo.carlini at oracle dot com
  2011-10-12 22:14 ` paolo.carlini at oracle dot com
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 10+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-10-12 21:41 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011-10-12
                 CC|gcc-bugs at gcc dot gnu.org |jason at gcc dot gnu.org
     Ever Confirmed|0                           |1

--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-10-12 21:41:14 UTC ---
Jason, this has been reported two times and it's pretty old, but doesn't seem
to me very hard to fix?!? Any tips about where the built-in candidates are
generated / managed?


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

* [Bug c++/38174] Missing some built-in candidates for operator overloading
       [not found] <bug-38174-4@http.gcc.gnu.org/bugzilla/>
  2011-10-12 21:38 ` [Bug c++/38174] Missing some built-in candidates for operator overloading paolo.carlini at oracle dot com
  2011-10-12 21:41 ` paolo.carlini at oracle dot com
@ 2011-10-12 22:14 ` paolo.carlini at oracle dot com
  2011-10-13  2:50 ` jason at gcc dot gnu.org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 10+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-10-12 22:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-10-12 22:14:03 UTC ---
So, for operator== for example, we reach the end of add_builtin_candidate, the
conditional is true, and we proceed with two calls to build_builtin_candidate
for pairs of const int* and pairs of volatile int*, I don't see the analysis
required to figure out that we need also the version for pairs of const
volatile int*. Should be open coded here?


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

* [Bug c++/38174] Missing some built-in candidates for operator overloading
       [not found] <bug-38174-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2011-10-12 22:14 ` paolo.carlini at oracle dot com
@ 2011-10-13  2:50 ` jason at gcc dot gnu.org
  2011-10-13  9:39 ` paolo.carlini at oracle dot com
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu.org @ 2011-10-13  2:50 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> 2011-10-13 02:49:30 UTC ---
(In reply to comment #3)
> So, for operator== for example, we reach the end of add_builtin_candidate, the
> conditional is true, and we proceed with two calls to build_builtin_candidate
> for pairs of const int* and pairs of volatile int*, I don't see the analysis
> required to figure out that we need also the version for pairs of const
> volatile int*. Should be open coded here?

In the code where we generate those two pairs, if the two pointers have a
composite pointer type, we should instead generate a single candidate with that
type.


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

* [Bug c++/38174] Missing some built-in candidates for operator overloading
       [not found] <bug-38174-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2011-10-13  2:50 ` jason at gcc dot gnu.org
@ 2011-10-13  9:39 ` paolo.carlini at oracle dot com
  2011-10-13 14:27 ` jason at redhat dot com
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 10+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-10-13  9:39 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-10-13 09:38:57 UTC ---
Thanks Jason, I thought we had to purely *add* overloads. Therefore we'll have
to refactor the code a bit I guess, to always have a single call at the end of
add_builtin_candidate. For the record, yesterday was playing with things like
the below. I hope the additional code eventually will not be *much* more
complex, maybe I will be able to help...

//////////////

Index: call.c
===================================================================
--- call.c    (revision 179867)
+++ call.c    (working copy)
@@ -2582,6 +2582,28 @@
       || MAYBE_CLASS_TYPE_P (type1)
       || TREE_CODE (type1) == ENUMERAL_TYPE))
     {
+      tree type1_type = TREE_TYPE (type1);
+      tree type2_type = TREE_TYPE (type2);
+      
+      if (TYPE_PTR_P (type1) && TYPE_PTR_P (type2)
+      && same_type_p (TYPE_MAIN_VARIANT (type1_type),
+              TYPE_MAIN_VARIANT (type2_type)))
+    {
+      if ((CP_TYPE_CONST_P (type1_type)
+           && CP_TYPE_VOLATILE_P (type2_type))
+          || (CP_TYPE_VOLATILE_P (type1_type)
+          && CP_TYPE_CONST_P (type2_type)))
+        {
+          tree ctype
+        = build_pointer_type
+        (cp_build_qualified_type (TYPE_MAIN_VARIANT (type1_type),
+                      (TYPE_QUAL_CONST
+                       | TYPE_QUAL_VOLATILE)));
+          build_builtin_candidate
+        (candidates, fnname, ctype, ctype, args, argtypes, flags);
+        }
+    }
+
       build_builtin_candidate
     (candidates, fnname, type1, type1, args, argtypes, flags);
       build_builtin_candidate


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

* [Bug c++/38174] Missing some built-in candidates for operator overloading
       [not found] <bug-38174-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2011-10-13  9:39 ` paolo.carlini at oracle dot com
@ 2011-10-13 14:27 ` jason at redhat dot com
  2011-10-14  0:20 ` paolo.carlini at oracle dot com
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 10+ messages in thread
From: jason at redhat dot com @ 2011-10-13 14:27 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Jason Merrill <jason at redhat dot com> 2011-10-13 14:27:12 UTC ---
Just use composite_pointer_type.  :)

Jason


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

* [Bug c++/38174] Missing some built-in candidates for operator overloading
       [not found] <bug-38174-4@http.gcc.gnu.org/bugzilla/>
                   ` (5 preceding siblings ...)
  2011-10-13 14:27 ` jason at redhat dot com
@ 2011-10-14  0:20 ` paolo.carlini at oracle dot com
  2011-10-14  1:43 ` paolo.carlini at oracle dot com
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 10+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-10-14  0:20 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |paolo.carlini at oracle dot
                   |                            |com

--- Comment #7 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-10-14 00:19:43 UTC ---
Eh, eh, I hadn't realized that composite pointer type isn't just a term of art
(which, to be honest, I didn't really know well, meant to study) but also an
actual function! Looks like the whole fix could be quite elegant!


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

* [Bug c++/38174] Missing some built-in candidates for operator overloading
       [not found] <bug-38174-4@http.gcc.gnu.org/bugzilla/>
                   ` (6 preceding siblings ...)
  2011-10-14  0:20 ` paolo.carlini at oracle dot com
@ 2011-10-14  1:43 ` paolo.carlini at oracle dot com
  2011-10-14 14:43 ` paolo at gcc dot gnu.org
  2011-10-14 14:45 ` paolo.carlini at oracle dot com
  9 siblings, 0 replies; 10+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-10-14  1:43 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|paolo.carlini at oracle dot |
                   |com                         |
         AssignedTo|unassigned at gcc dot       |paolo.carlini at oracle dot
                   |gnu.org                     |com


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

* [Bug c++/38174] Missing some built-in candidates for operator overloading
       [not found] <bug-38174-4@http.gcc.gnu.org/bugzilla/>
                   ` (7 preceding siblings ...)
  2011-10-14  1:43 ` paolo.carlini at oracle dot com
@ 2011-10-14 14:43 ` paolo at gcc dot gnu.org
  2011-10-14 14:45 ` paolo.carlini at oracle dot com
  9 siblings, 0 replies; 10+ messages in thread
From: paolo at gcc dot gnu.org @ 2011-10-14 14:43 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> 2011-10-14 14:43:06 UTC ---
Author: paolo
Date: Fri Oct 14 14:43:03 2011
New Revision: 179984

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=179984
Log:
/cp
2011-10-14  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/38174
    * call.c (add_builtin_candidate): If two pointers have a composite
    pointer type, generate a single candidate with that type.

/testsuite
2011-10-14  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/38174
    * g++.dg/overload/operator4.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/overload/operator4.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/call.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug c++/38174] Missing some built-in candidates for operator overloading
       [not found] <bug-38174-4@http.gcc.gnu.org/bugzilla/>
                   ` (8 preceding siblings ...)
  2011-10-14 14:43 ` paolo at gcc dot gnu.org
@ 2011-10-14 14:45 ` paolo.carlini at oracle dot com
  9 siblings, 0 replies; 10+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-10-14 14:45 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

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

--- Comment #9 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-10-14 14:44:22 UTC ---
Fixed for 4.7.0.


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

end of thread, other threads:[~2011-10-14 14:45 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-38174-4@http.gcc.gnu.org/bugzilla/>
2011-10-12 21:38 ` [Bug c++/38174] Missing some built-in candidates for operator overloading paolo.carlini at oracle dot com
2011-10-12 21:41 ` paolo.carlini at oracle dot com
2011-10-12 22:14 ` paolo.carlini at oracle dot com
2011-10-13  2:50 ` jason at gcc dot gnu.org
2011-10-13  9:39 ` paolo.carlini at oracle dot com
2011-10-13 14:27 ` jason at redhat dot com
2011-10-14  0:20 ` paolo.carlini at oracle dot com
2011-10-14  1:43 ` paolo.carlini at oracle dot com
2011-10-14 14:43 ` paolo at gcc dot gnu.org
2011-10-14 14:45 ` paolo.carlini at oracle dot com

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).