From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id A7ECB398382C for ; Thu, 22 Jul 2021 09:19:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A7ECB398382C Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-456-ELWseKCpMWS6IQX3V8Ctgw-1; Thu, 22 Jul 2021 05:19:29 -0400 X-MC-Unique: ELWseKCpMWS6IQX3V8Ctgw-1 Received: by mail-wr1-f69.google.com with SMTP id h11-20020adffa8b0000b029013a357d7bdcso2206112wrr.18 for ; Thu, 22 Jul 2021 02:19:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-language:content-transfer-encoding; bh=kjWlZRX0O4emGmLfmrFN4E5jvq3//O40l4YKofO0g4E=; b=jHu+O6k4h4IRneoUV7emZKtcPKlKb4rmzTZGJM9zWmASvTiPFQMyCGSmRDhtffe/9P Y+/Y4MNAbhTu8tQHrivzNhuYeLVFu4DUcwGJ3SDt4OrmTYy6XdjKoTEZ/Qx9NEJcSm/k +XzVhBhJ6iFhj1ozxUcKBlySeY66tJPsNwwqC5NXboQizoOnt9D9X9rWQI0N3lgEyRcD AA5+aOFxKYSvCCwzo3RnCE8+kO21aDudjsIIpF2Ofj1OMLmoMKEgYNNsi0rcmappiPgr nUZsqUuJCtj2ZUEqyv1HtFTy4DzkXEfA2Tr+yF4ag/6SFnXo9BYO/NPcglh/Nt/d2ofA oeDQ== X-Gm-Message-State: AOAM531TZtd82/aG2kzUI+hIARhzKzcgbUJcz1cowrLPj+OrKd4lv0Uv AZmAIZcmWrFD5WdspCKbKOk81tfwHMc32i9tIN1sXjB/n4OBNsio0Cgqwfz2nZOPrSsSWJcsMvw R3fDv/NHGQwCRjxMH2pGTlutfSyWLbOtfryMZJlsOwrhqif51jLHNER1ZJr2ilsgceUU= X-Received: by 2002:adf:a1c2:: with SMTP id v2mr47263017wrv.155.1626945568491; Thu, 22 Jul 2021 02:19:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyrnUwkkJ25RKMSRGscuAZeW9+afHPtYBXjBJSBnOpUGBhPOIm1QcSi6w9k/PObXWyc833ocg== X-Received: by 2002:adf:a1c2:: with SMTP id v2mr47262996wrv.155.1626945568220; Thu, 22 Jul 2021 02:19:28 -0700 (PDT) Received: from [192.168.188.47] (dynamic-077-000-028-105.77.0.pool.telefonica.de. [77.0.28.105]) by smtp.gmail.com with ESMTPSA id j23sm1979685wmo.26.2021.07.22.02.19.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 22 Jul 2021 02:19:27 -0700 (PDT) To: gcc@gcc.gnu.org, libstdc++@gcc.gnu.org From: Stephan Bergmann Subject: More aggressive GCC 12 -Wmaybe-uninitialized when using Message-ID: <2a9e7039-b23b-b0d6-c34f-56a1957df591@redhat.com> Date: Thu, 22 Jul 2021 11:19:26 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Jul 2021 09:19:37 -0000 Compared to GCC 11 (at least gcc-c++-11.1.1-3.fc34.x86_64), recent GCC 12 trunk emits two "unhelpful" -Wmaybe-uninitialized for > $ cat test.cc > #include > using fn = std::function; > fn f(fn x) { > fn a; > a = x; > return x; > } > $ ~/gcc/trunk/inst/bin/g++ -c -Wmaybe-uninitialized -O2 test.cc > In file included from ~/gcc/trunk/inst/include/c++/12.0.0/bits/stl_function.h:60, > from ~/gcc/trunk/inst/include/c++/12.0.0/functional:49, > from test.cc:1: > In function ‘std::_Require >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> > std::swap(_Tp&, _Tp&) [with _Tp = void (*)(const std::_Any_data&)]’, > inlined from ‘void std::function<_Res(_ArgTypes ...)>::swap(std::function<_Res(_ArgTypes ...)>&) [with _Res = void; _ArgTypes = {}]’ at ~/gcc/trunk/inst/include/c++/12.0.0/bits/std_function.h:529:11, > inlined from ‘std::function<_Res(_ArgTypes ...)>& std::function<_Res(_ArgTypes ...)>::operator=(const std::function<_Res(_ArgTypes ...)>&) [with _Res = void; _ArgTypes = {}]’ at ~/gcc/trunk/inst/include/c++/12.0.0/bits/std_function.h:442:20, > inlined from ‘fn f(fn)’ at test.cc:5:9: > ~/gcc/trunk/inst/include/c++/12.0.0/bits/move.h:204:11: warning: ‘.std::function::_M_invoker’ may be used uninitialized [-Wmaybe-uninitialized] > 204 | _Tp __tmp = _GLIBCXX_MOVE(__a); > | ^~~~~ > In file included from ~/gcc/trunk/inst/include/c++/12.0.0/functional:59, > from test.cc:1: > ~/gcc/trunk/inst/include/c++/12.0.0/bits/std_function.h: In function ‘fn f(fn)’: > ~/gcc/trunk/inst/include/c++/12.0.0/bits/std_function.h:442:9: note: ‘’ declared here > 442 | function(__x).swap(*this); > | ^~~~~~~~~~~~~ > In file included from ~/gcc/trunk/inst/include/c++/12.0.0/bits/stl_function.h:60, > from ~/gcc/trunk/inst/include/c++/12.0.0/functional:49, > from test.cc:1: > In function ‘std::_Require >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> > std::swap(_Tp&, _Tp&) [with _Tp = std::_Any_data]’, > inlined from ‘void std::function<_Res(_ArgTypes ...)>::swap(std::function<_Res(_ArgTypes ...)>&) [with _Res = void; _ArgTypes = {}]’ at ~/gcc/trunk/inst/include/c++/12.0.0/bits/std_function.h:527:11, > inlined from ‘std::function<_Res(_ArgTypes ...)>& std::function<_Res(_ArgTypes ...)>::operator=(const std::function<_Res(_ArgTypes ...)>&) [with _Res = void; _ArgTypes = {}]’ at ~/gcc/trunk/inst/include/c++/12.0.0/bits/std_function.h:442:20, > inlined from ‘fn f(fn)’ at test.cc:5:9: > ~/gcc/trunk/inst/include/c++/12.0.0/bits/move.h:204:11: warning: ‘*(std::_Any_data*)((char*)& + offsetof(std::function, std::function::))’ may be used uninitialized [-Wmaybe-uninitialized] > 204 | _Tp __tmp = _GLIBCXX_MOVE(__a); > | ^~~~~ > In file included from ~/gcc/trunk/inst/include/c++/12.0.0/functional:59, > from test.cc:1: > ~/gcc/trunk/inst/include/c++/12.0.0/bits/std_function.h: In function ‘fn f(fn)’: > ~/gcc/trunk/inst/include/c++/12.0.0/bits/std_function.h:442:9: note: ‘’ declared here > 442 | function(__x).swap(*this); > | ^~~~~~~~~~~~~ This appears to be an issue with more aggressive -Wmaybe-uninitialized in GCC 12 vs. 11, rather than an issue with changes to in libstdc++ 12 vs. 11, as effectively the same warnings are emitted when I use GCC 12 with libstdc++ 11 with > $ ~/gcc/trunk/inst/bin/g++ -c -Wmaybe-uninitialized -O2 -nostdinc++ -isystem /usr/include/c++/11 -isystem /usr/include/c++/11/x86_64-redhat-linux test.cc The warnings may technically be correct, and I'm not sure whether this is something that should be addressed in the GCC code emitting the warnings or in the libstdc++ implementation. (I found this when building LibreOffice with recent GCC 12 trunk.)