From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qt1-x82e.google.com (mail-qt1-x82e.google.com [IPv6:2607:f8b0:4864:20::82e]) by sourceware.org (Postfix) with ESMTPS id C8D513858D37 for ; Tue, 11 Aug 2020 13:55:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C8D513858D37 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=acm.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=nathanmsidwell@gmail.com Received: by mail-qt1-x82e.google.com with SMTP id s23so9412460qtq.12 for ; Tue, 11 Aug 2020 06:55:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=139x0PL0JXN2FhIC5H3g6FGIKlEZUvNFLdGUyR3m82c=; b=T4LzSmd7Knhi7tuRyzKxbEejAXvY39VSYLKQsV7fQWnTWqecye8/0mD1mAxrkuoBlH maB9i1KgzxmfXCneMVdryMhgSa/cgcbXkECc7CGC3tdyccVvBm0oiLHX7Gx4QkgOKrWs 0bTambNhOr5bWAv+LemvSC8MWQtmldeTtktabNlnfuLWmzEWtXCzw6GXQLnDRuNDx4ot mcBnOyg0qpRLDpmzlPhWeTMGHtajFW9BH9cNpZG8AXWdy+AZfW2Hpn8r8XqJ5nOrj3uQ 6he1a3/CDbuGfhE6voWlCVRqKIbKdy+KdTzrOR1wfu+CjWoIcp2+qtlIB1+DbHyMVWc2 +fPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=139x0PL0JXN2FhIC5H3g6FGIKlEZUvNFLdGUyR3m82c=; b=XOjvsvXVhVvS2WkqXpikRpvpRzbZ5EGGNRmDUxjawMr2Z2NeUr6rRDQI5SprnXEG5e M+do0Wr8YFwzLVRhwYFVteiyuwpcPS/QWO6gFxp2bmbokz6NT8cPZ+mGf9LAokHKm6pK Tuo96tYQ6Nr3hKWkWxk20E4RRiFFxh/SAmLBhFoEUMtK9qFOcMu3otJye2ftpMQ17umb vB7fZxXdMXa3wIiUH9dSXYZSkmkHFyIEMMTomGNyoE7GFEVUIEgP2KyQRJAlZZLhFmjJ gxzWXaY4RDgyfrFI12FQy7F7GH20x8WerViSWoD9dicNjlfONMEUp3zd88rBiAN0N2Lm Yxtw== X-Gm-Message-State: AOAM532xDibYQu4bh8uUWRJqaOXu9KLK7B19S5BmQo2GiQ7WowS/GpWT 7e76/iOZ6GhMVnlZkTSiyBc= X-Google-Smtp-Source: ABdhPJwAGzA7CNWClXqMevrDPZmyvnxJj/5KLxGboWIVbPKiKdXW4FKeg5uTp90qaF15v6EUK3IoXw== X-Received: by 2002:ac8:1344:: with SMTP id f4mr1170462qtj.285.1597154112921; Tue, 11 Aug 2020 06:55:12 -0700 (PDT) Received: from ?IPv6:2620:10d:c0a8:1102:145f:3db9:a76:864b? ([2620:10d:c091:480::1:29e2]) by smtp.googlemail.com with ESMTPSA id 22sm16043214qkg.24.2020.08.11.06.55.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 11 Aug 2020 06:55:12 -0700 (PDT) Sender: Nathan Sidwell Subject: Re: Coding style for C++ constructs going forward To: Luis Machado , "gdb@sourceware.org" , gcc Mailing List , Pedro Alves , Simon Marchi References: <33412819-8a5e-0c7f-7cfb-f3d127dc2242@linaro.org> From: Nathan Sidwell Message-ID: Date: Tue, 11 Aug 2020 09:55:10 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <33412819-8a5e-0c7f-7cfb-f3d127dc2242@linaro.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, KAM_SHORT, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Aug 2020 13:55:15 -0000 On 8/7/20 10:06 AM, Luis Machado via Gcc wrote: > Hi, > > cc-ing the GCC mailing list, as we may want to use the same coding style > for GDB and GCC. > > Yesterday I brought this topic up on IRC. I notice we started using more > and more the "auto" keyword. In some cases, this is actually useful and > makes the code a bit more compact. GDB has been using those more often, > whereas GCC, for example, isn't using those too much. > > Looking at the coding standards for GCC > (https://gcc.gnu.org/codingconventions.html), I don't see anything > dictating best practices for "auto" use. > > I guess it is a consensus that "auto" is a good fit when dealing with > iterators, lambda's and gnarly templates (but only when the type is > already obvious from its use). > > There are other situations where "auto" may make things a little more > cryptic when one wants to figure out the types of the variables. One > example of this is when you have a longer function, and you use "auto" > in a variable that lives throughout the scope of the function. This > means you'll need to go back to its declaration and try to figure out > what type this particular variable has. > > Pedro has pointed out LLVM's coding standards for "auto", which we may > or may not want to follow/adopt: > https://llvm.org/docs/CodingStandards.html#use-auto-type-deduction-to-make-code-more-readable > > > It sounds like a reasonable idea to me. Thoughts? I agree, it's the way I use auto. I particularly like the auto *foo = expr; idiom, when you're getting a pointer, but the type of the pointee is clear. It informs how you use 'foo'. > > Are there other C++ constructs people think would benefit from a more > formal style guideline? As we move to newer C++ standards over time, it > is more likely we will start using newer constructs, and some of those > may make the code potentially less readable. -- Nathan Sidwell