In the following code 'const VR' in declaration of the return value of 'kk'
works as just 'VR', without constness.

In arguments 'const VR' is applied as const.

---- code example ----
typedef int X;

struct S {
  typedef X& VR; // <--- VR is declared as X by-reference
  X x;
  // uncomment one of these two lines:
  const VR kk(VR) const { return (x); }     // <--- bug: first 'const' is
ignored and function is defined as returning *not* const causing compiler error
message
  // const X& kk(VR) const { return (x); }  // <--- ok: function is defined as
returning const by-reference
};

void f() {
  typedef S::VR VR;
  const X& (S::*fn)(VR) const; // <---: ask for the function returning
by-reference
  fn = &S::kk; // <--- error message here
}


-- 
           Summary: 'const' attribute applied to typedefed type in methods's
                    return is ignored
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: yuri at tsoft dot com


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

Reply via email to