From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from wp525.webpack.hosteurope.de (wp525.webpack.hosteurope.de [IPv6:2a01:488:42:1000:50ed:822f::]) by sourceware.org (Postfix) with ESMTPS id 4A079385802E for ; Fri, 11 Jun 2021 19:37:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4A079385802E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=faehling.com Authentication-Results: sourceware.org; spf=none smtp.mailfrom=faehling.com Received: from [2a02:810d:1380:fbc::f670]; authenticated by wp525.webpack.hosteurope.de running ExIM with esmtpsa (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) id 1lrmxk-0002cB-P3; Fri, 11 Jun 2021 21:37:04 +0200 To: gcc@gcc.gnu.org From: Markus Faehling Subject: GCC/clang warning incompatibility with unused private member variables Message-ID: <5f5ddb1f-39f7-d858-e1c5-afff73043df3@faehling.com> Date: Fri, 11 Jun 2021 21:37:04 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-bounce-key: webpack.hosteurope.de;markus@faehling.com;1623440226;4c675617; X-HE-SMSGID: 1lrmxk-0002cB-P3 X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_NONE, SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Jun 2021 19:37:07 -0000 Hello, I'm currently facing a problem where I cannot get both gcc and clang warning-free simultaneously in my project. My code looks somewhat like this: class Test {     int a_;     void b() {}; }; This code gives me the(usually very useful) "-Wunused-private-field" warning on clang. But because I have the unused member on purpose, I would like to add the [[maybe_unused]] attribute to it: class Test {     [[maybe_unused]] int a_;     void b() {}; }; While this version is warning-free in clang, gcc has a "-Wattributes" warning because it ignores the [[maybe_unused]] warning. But I do not want to disable either of these warnings because they are still very useful in other situations. Would it be possible to ignore the "-Wattributes" warning for [[maybe_unused]] in places where other compilers might use the attribute? Demonstration on godbolt.org: https://godbolt.org/z/8oT4Kr5eM Regards, Markus Faehling