From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Eli Zaretskii" To: dan@cgsoftware.com Cc: gdb@sources.redhat.com Subject: Re: Cast to a struct in expressions Date: Sat, 28 Apr 2001 01:08:00 -0000 Message-id: <8011-Sat28Apr2001110937+0300-eliz@is.elta.co.il> References: <8011-Fri27Apr2001111107+0300-eliz@is.elta.co.il> <6137-Fri27Apr2001204221+0300-eliz@is.elta.co.il> <168339.988385422@dynamic-addr-83-177.resnet.rochester.edu> X-SW-Source: 2001-04/msg00209.html > Date: Fri, 27 Apr 2001 15:30:22 -0400 > From: Daniel Berlin > > > > I'm still missing something, because I don't see how "*(struct foo *)x" > > differs from "*(struct {long foo; unsigned bar;} *)x". Both are valid > > C expression syntax, so the parser should be able to parse them both. > > No, they aren't both *expressions*, only one is. > One is a statement/declaration, and the other is an expression. I'm not a C language expert, but my references seem to disagree with you. The "cast-expression" is defined as having the form cast-expression: unary-expression ( type-name ) cast-expression and "type-name" is syntactically a declaration for a function or an object of that type with the object identifier omitted. > No. It's done on purpose. We aren't supposed to be handling statements and > declarations, only expressions. > > Doing more would require making the C parser into a mini-C compiler. > You'd have to start injecting types into the symbol table and whatnot. I think I understand the trade-offs and appreciate the problems. I'm not saying GDB must support such expressions, but the language definition seems to say it's an expression, so users might expect them to be supported. Perhaps something should be said in the docs.