This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] gdb: Use vector::emplace_back


On Wednesday, November 09, 2016 03:27:05 PM Pedro Alves wrote:
> On 11/09/2016 02:48 PM, John Baldwin wrote:
> > On Wednesday, November 09, 2016 12:55:52 PM Pedro Alves wrote:
> >> On 11/09/2016 12:42 PM, Yao Qi wrote:
> >>
> >>> I know leading underscore is used in some projects, so I want to know
> >>> is it a C++ code standard that we use trailing underscore in this case or
> >>> it is your personal coding habit.  It is the latter.
> >>
> >> ...
> >>
> >>> Since the trailing underscore usage like this is not mentioned in C++
> >>> code standard, people are free to use or not to use it.  I don't have
> >>> a preference on that.
> >>
> >> OK.  I may ask a couple gcc people for their preference and see about
> >> adding it to the docs.  Each detail in the standard is based on 
> >> someone's personal preference that had sufficient following/agreement,
> >> after all.  :-)
> > 
> > If the goal is to support -Wshadow then it would be nice to settle on a style
> > so it is consistent across the tree.
> 
> It's not really about -Wshadow.  In C++, in order to use a
> member initializer, like in: 
> 
>   cmdarg (cmdarg_kind type_, char *string_)
>     : type (type_), string (string_)
>   {}
> 
> The parameter names really must be different from the
> struct's elements.
> 
> This:
> 
>   cmdarg (cmdarg_kind type, char *string)
>     : this->type (type), this->string (string)
>   {}
> 
> is not valid C++ and does _not_ compile:

No, but this compiles:

   cmdarg (cmdarg_kind type, char *string)
     : type (type), string (string)
   {}

I converted a non-trivial C++ code base both to C++11 and to compile with
-Wshadow (two of several different passes).  There were many instances of the
style above that all had to be changed to compile with -Wshadow.

-- 
John Baldwin


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]