From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24109 invoked by alias); 9 Nov 2016 17:08:23 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 24026 invoked by uid 89); 9 Nov 2016 17:08:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_SOFTFAIL autolearn=no version=3.3.2 spammy=settle, personal X-HELO: mail.baldwin.cx Received: from bigwig.baldwin.cx (HELO mail.baldwin.cx) (96.47.65.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 09 Nov 2016 17:08:20 +0000 Received: from ralph.baldwin.cx (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by mail.baldwin.cx (Postfix) with ESMTPSA id 909B410A735; Wed, 9 Nov 2016 12:08:18 -0500 (EST) From: John Baldwin To: gdb-patches@sourceware.org Cc: Pedro Alves , Yao Qi Subject: Re: [PATCH] gdb: Use vector::emplace_back Date: Wed, 09 Nov 2016 17:08:00 -0000 Message-ID: <2148985.sxa6D4FU0N@ralph.baldwin.cx> User-Agent: KMail/4.14.10 (FreeBSD/11.0-PRERELEASE; KDE/4.14.10; amd64; ; ) In-Reply-To: <79425cad-160f-d1a2-3275-29605db7a7cb@redhat.com> References: <1478651991-5083-1-git-send-email-palves@redhat.com> <1575403.749fUSKQim@ralph.baldwin.cx> <79425cad-160f-d1a2-3275-29605db7a7cb@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-IsSubscribed: yes X-SW-Source: 2016-11/txt/msg00232.txt.bz2 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