Bug 18166

Summary: top const stripped in structs for C
Product: gcc Reporter: Mike Stump <mikestump>
Component: cAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: minor CC: gcc-bugs, jsm28
Priority: P2 Keywords: wrong-debug
Version: 4.0.0   
Target Milestone: 4.0.0   
Host: Target: powerpc-darwin
Build: Known to work:
Known to fail: Last reconfirmed: 2005-01-25 03:43:48

Description Mike Stump 2004-10-26 23:24:01 UTC
The following doesn't produce accurate dbx stabs information on powerpc-apple-darwin:

struct ssc { char * const ptr; };
struct ss { char * ptr; };

int main ()
{
  struct ssc xssc;
  struct ss xss;
}

(gdb) ptype xss
type = struct ss {
    char *ptr;
}
(gdb) ptype xssc
type = struct ssc {
    char *ptr;
}

http://gcc.gnu.org/ml/gcc-patches/2002-10/msg01872.html has a wrong patch.  The corresponding 
C++ code works as expected.

Radar 3085329
Comment 1 Mike Stump 2004-10-26 23:27:19 UTC
For reference, the C++ version:

struct ssc { char * const ptr;
  ssc () :ptr(0) { }
};
struct ss { char * ptr; };

int main ()
{
  struct ssc xssc;
  struct ss xss;
}

and its output:

(gdb) ptype xss
type = struct ss {
    char *ptr;
}
(gdb) ptype xssc
type = class ssc {
  public:
    char * const ptr;

    ssc(ssc const&);
    ssc();
}
Comment 2 Andrew Pinski 2004-10-26 23:30:54 UTC
Confirmed.
Comment 3 Joseph S. Myers 2005-01-29 16:31:55 UTC
My patch <http://gcc.gnu.org/ml/gcc-patches/2005-01/msg02180.html>
should cause fields to be given the correct types within the C front
end, and might thereby fix this bug.
Comment 4 Joseph S. Myers 2005-03-19 13:23:07 UTC
Could someone with a Darwin build to hand check whether this bug is indeed fixed
as I suggest in my previous comment?
Comment 5 Andrew Pinski 2005-03-20 17:45:36 UTC
Confirmed as fixed:
(gdb) ptype xss
type = struct ss {
    char *ptr;
}
(gdb) ptype xssc
type = struct ssc {
    char * const ptr;
}