[Bug c++/12370] [3.4 regression] wrong code involving friends

bangerth at dealii dot org gcc-bugzilla@gcc.gnu.org
Mon Sep 22 22:19:00 GMT 2003


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

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


bangerth at dealii dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2003-09-22 21:15:15
               date|                            |
   Target Milestone|---                         |3.4


------- Additional Comments From bangerth at dealii dot org  2003-09-22 21:15 -------
Confirmed. There's something odd going on here. It's not
a problem with signed vs unsigned, btw, since we have the
same behavior with this testcase:
------------------------------
struct B {
    int x;
};

template <int=0> struct A
{
    int x;
    friend B foo (const A<>&);
};

B foo (const A<>& a) { B res = {a.x};  return res; }

int main()
{
  return foo((A<>){0}).x;
}
---------------------------------
This returns 120 on my system (and the original testcase returned 84 here,
so this seems to be mostly random). I don't know what the friend declaration
can have possibly to do with the result, but removing it really makes
the bug go away. Likewise for making A a non-template...

W.



More information about the Gcc-bugs mailing list