From patchwork Wed Dec 9 23:07:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Sebor X-Patchwork-Id: 554845 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 811F2140CA4 for ; Thu, 10 Dec 2015 10:07:17 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=nZA+hNxB; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=JwH5W68jm+hH/woxBv+JyKHew2CO1WxkkYjezg2FLvj/Xo mKkpWvToV4kWpky43KovT2UXZgT3faNl3Z6S93TFu8BPbTIcUzRG8RFyMGTxgDPy cLq6/H08933EJJpDhTOfl/qV4kmDpABLQNuv+hHwNjm+f/hcj8BfuqH2Nxo7k= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=J0+GBsumbC/HWItdlUTMcdxfOYY=; b=nZA+hNxB705d7w+KFxi6 qTckBF/hBeRYuxrV8sNER2FIXFnXS0JfqnR55eW7ZOY4lRE7ZjeG2jElMDtFNQwP /m5fHUzyE8UGGrbul9+pg0yvVwMmw9mgNepREAFbJVT5cAuob+mzZLNgDPqFg1Kk WaRgv9DEjfWiymqjNuUhD+4= Received: (qmail 91998 invoked by alias); 9 Dec 2015 23:07:10 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 91989 invoked by uid 89); 9 Dec 2015 23:07:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-qg0-f53.google.com Received: from mail-qg0-f53.google.com (HELO mail-qg0-f53.google.com) (209.85.192.53) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 09 Dec 2015 23:07:08 +0000 Received: by qgeb1 with SMTP id b1so106597634qge.1 for ; Wed, 09 Dec 2015 15:07:06 -0800 (PST) X-Received: by 10.140.169.130 with SMTP id p124mr2231971qhp.50.1449702426056; Wed, 09 Dec 2015 15:07:06 -0800 (PST) Received: from [192.168.0.26] (97-124-162-152.hlrn.qwest.net. [97.124.162.152]) by smtp.gmail.com with ESMTPSA id e62sm4776840qga.47.2015.12.09.15.07.04 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Dec 2015 15:07:05 -0800 (PST) Message-ID: <5668B417.8070604@gmail.com> Date: Wed, 09 Dec 2015 16:07:03 -0700 From: Martin Sebor User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Gcc Patch List Subject: [PATCH] update -Wall and -Wextra documentation X-IsSubscribed: yes A number of warning options are missing from the list shown under -Wall (for example, -Winit-self, -Wlogical-not-parentheses, and -Wplacement-new). The patch adds the missing ones and adjusts some of the existing ones to maintain an alphabetical order. It also makes a couple of minor clarifications to -Wextra, and adds an example to the -Wplacement-new option. Martin 2015-12-09 Martin Sebor * invoke.texi (Warning Options): Update -Wall options. Clarify when some -Wextra options are enabled. Add -Wplacement-new example. Index: invoke.texi =================================================================== --- invoke.texi (revision 231436) +++ invoke.texi (working copy) @@ -3541,26 +3541,33 @@ @gccoptlist{-Waddress @gol -Warray-bounds=1 @r{(only with} @option{-O2}@r{)} @gol +-Wbool-compare @gol -Wc++11-compat -Wc++14-compat@gol -Wchar-subscripts @gol +-Wcomment @gol +-Wduplicated-cond @gol -Wenum-compare @r{(in C/ObjC; this is on by default in C++)} @gol +-Wformat @gol +-Wimplicit @r{(C and Objective-C only)} @gol -Wimplicit-int @r{(C and Objective-C only)} @gol -Wimplicit-function-declaration @r{(C and Objective-C only)} @gol --Wbool-compare @gol --Wduplicated-cond @gol --Wcomment @gol --Wformat @gol +-Winit-self @r{(only for C++)} @gol +-Wlogical-not-parentheses -Wmain @r{(only for C/ObjC and unless} @option{-ffreestanding}@r{)} @gol -Wmaybe-uninitialized @gol +-Wmemset-transposed-args @gol -Wmissing-braces @r{(only for C/ObjC)} @gol +-Wnarrowing @r{(only for C++)} @gol -Wnonnull @gol -Wopenmp-simd @gol -Wparentheses @gol +-Wplacement-new @r{(only for C++)} @gol -Wpointer-sign @gol -Wreorder @gol -Wreturn-type @gol -Wsequence-point @gol -Wsign-compare @r{(only in C++)} @gol +-Wsizeof-pointer-memaccess @gol -Wstrict-aliasing @gol -Wstrict-overflow=1 @gol -Wswitch @gol @@ -3598,10 +3605,10 @@ -Wmissing-parameter-type @r{(C only)} @gol -Wold-style-declaration @r{(C only)} @gol -Woverride-init @gol --Wsign-compare @gol +-Wsign-compare @r{(C only)} @gol -Wtype-limits @gol -Wuninitialized @gol --Wshift-negative-value @gol +-Wshift-negative-value @r{(in C++03 and in C99 and newer)} @gol -Wunused-parameter @r{(only with} @option{-Wunused} @r{or} @option{-Wall}@r{)} @gol -Wunused-but-set-parameter @r{(only with} @option{-Wunused} @r{or} @option{-Wall}@r{)} @gol } @@ -4895,8 +4902,15 @@ @opindex Wno-placement-new Warn about placement new expressions with undefined behavior, such as constructing an object in a buffer that is smaller than the type of -the object. - +the object. For example, the placement new expression below is diagnosed +because it attempts to construct an array of 64 integers in a buffer only +64 bytes large. +@smallexample +char buf [64]; +new (buf) int[64]; +@end smallexample +This warning is enabled by @option{-Wall}. + @item -Wpointer-arith @opindex Wpointer-arith @opindex Wno-pointer-arith @@ -5113,8 +5127,9 @@ @cindex signed and unsigned values, comparison warning Warn when a comparison between signed and unsigned values could produce an incorrect result when the signed value is converted to unsigned. -This warning is also enabled by @option{-Wextra}; to get the other warnings -of @option{-Wextra} without this warning, use @option{-Wextra -Wno-sign-compare}. +In C++, this warning is also enabled by @option{-Wall}. In C, it is also +enabled by @option{-Wextra}; to get the other warnings of @option{-Wextra} +without this warning, use @option{-Wextra -Wno-sign-compare}. @item -Wsign-conversion @opindex Wsign-conversion