public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/90844] New: Another case of missing use of uninitialized variable warning
@ 2019-06-11 21:03 subscriptions-gnu at vsbe dot com
  2021-04-15 22:55 ` [Bug middle-end/90844] missing -Wmaybe-uninitialized with -flto and optimization msebor at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: subscriptions-gnu at vsbe dot com @ 2019-06-11 21:03 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90844

            Bug ID: 90844
           Summary: Another case of missing use of uninitialized variable
                    warning
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: subscriptions-gnu at vsbe dot com
  Target Milestone: ---

this is somewhat similar to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=18501,
but a bit different. Here is the code to trigger the problem:

vvvvvvvvvvv  try.c  vvvvvvvvvvvvvvvvvvvvvvvvvvv
static int func1(int x) { return 1; }

static int func2(void)
{
        int number;
        if (func2() == 0) number += func1(0);
        return number;
}

int main(int argc, char **argv)
{
        int counter;
        counter +=  func2();
        return counter;
}
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Running on 4.19.28-2 x86_64 GNU/Linux, using compiler version

vvvvvvvvvvvvvvvvvvvvvvvvvvvv
arm-eabi-gcc  -v
Using built-in specs.
COLLECT_GCC=/usr/local/google/home/vbendeb/new_projects/1grepo/chroot/opt/coreboot-sdk/bin/arm-eabi-gcc
COLLECT_LTO_WRAPPER=/usr/local/google/home/vbendeb/new_projects/1grepo/chroot/opt/coreboot-sdk/bin/../lib/gcc/arm-eabi/8.3.0/lto-wrapper
Target: arm-eabi
Configured with: ../gcc-8.3.0/configure --prefix=/opt/coreboot-sdk
--libexecdir=/opt/coreboot-sdk/lib --target=arm-eabi --disable-werror
--disable-shared --enable-lto --enable-plugins --enable-gold
--enable-ld=default --disable-libssp --disable-bootstrap --disable-nls
--disable-libquadmath --without-headers --disable-threads --enable-interwork
--enable-multilib --enable-targets=all --disable-libatomic --disable-libcc1
--disable-decimal-float --enable-languages=c,ada --with-system-zlib
--with-gmp=/var/tmp/portage/dev-embedded/coreboot-sdk-0.0.1-r74/work/coreboot-sdk-0.0.1/out/opt/coreboot-sdk
--with-mpfr=/var/tmp/portage/dev-embedded/coreboot-sdk-0.0.1-r74/work/coreboot-sdk-0.0.1/out/opt/coreboot-sdk
--with-mpc=/var/tmp/portage/dev-embedded/coreboot-sdk-0.0.1-r74/work/coreboot-sdk-0.0.1/out/opt/coreboot-sdk
--with-gnu-as --with-gnu-ld --with-pkgversion='coreboot toolchain v '
Thread model: single
gcc version 8.3.0 (coreboot toolchain v ) 
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


The below invocation properly highlights two instance of the uninitialized
variable assignment:

$ arm-eabi-gcc -Wall -o try.o -c try.c
try.c: In function 'func2':
try.c:7:34: warning: 'number' may be used uninitialized in this function
[-Wmaybe-uninitialized]
         if (func2() == 0) number += func1(0);
                                  ^~
try.c: In function 'main':
try.c:14:17: warning: 'counter' is used uninitialized in this function
[-Wuninitialized]
         counter +=  func2();
                 ^~
$





The following invocation triggers only one warning:

$ arm-eabi-gcc -Wall -Os -flto  -o try.o -c try.c
try.c: In function 'main':
try.c:14:17: warning: 'counter' is used uninitialized in this function
[-Wuninitialized]
         counter +=  func2();
                 ^~
$
>From gcc-bugs-return-646368-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Jun 11 21:57:06 2019
Return-Path: <gcc-bugs-return-646368-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 79942 invoked by alias); 11 Jun 2019 21:57:05 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 79898 invoked by uid 48); 11 Jun 2019 21:57:02 -0000
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/90397] Incompatibility with clang-tidy on std::variant
Date: Tue, 11 Jun 2019 21:57:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: libstdc++
X-Bugzilla-Version: 9.1.1
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: redi at gcc dot gnu.org
X-Bugzilla-Status: RESOLVED
X-Bugzilla-Resolution: FIXED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: redi at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 9.2
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-90397-4-RugKDurSew@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-90397-4@http.gcc.gnu.org/bugzilla/>
References: <bug-90397-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2019-06/txt/msg00883.txt.bz2
Content-length: 1099

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90397

--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> ---
G++ allowed it because the mismatch was in a system header. If you use
-Wsystem-headers then GCC 9.1 gives a warning about it:

/xhome/jwakely/gcc/9.1.0/include/c++/9.1.0/variant: In instantiation of 'class
std::variant<A, B>':
var.cc:14:44:   required from here
/xhome/jwakely/gcc/9.1.0/include/c++/9.1.0/variant:1559:34: warning:
declaration of 'template<long unsigned int _Np, class _Vp> constexpr
decltype(auto) std::__detail::__variant::__get(_Vp&&)' has a different
exception specifier [-Wsystem-headers]
 1559 |  friend constexpr decltype(auto) __detail::__variant::__get(_Vp&& __v);
      |                                  ^~~~~~~~
/xhome/jwakely/gcc/9.1.0/include/c++/9.1.0/variant:263:5: note: from previous
declaration 'template<long unsigned int _Np, class _Variant> constexpr
decltype(auto) std::__detail::__variant::__get(_Variant&&) noexcept'
  263 |     __get(_Variant&& __v) noexcept
      |     ^~~~~


If you use -pedantic-errors then you get an error.
>From gcc-bugs-return-646369-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Jun 11 22:04:46 2019
Return-Path: <gcc-bugs-return-646369-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 85900 invoked by alias); 11 Jun 2019 22:04:45 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 85879 invoked by uid 55); 11 Jun 2019 22:04:42 -0000
From: "tkoenig at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/90744] [7/8/9/10 Regression] Bogus length for character temporaries passed to external procedures since r268992
Date: Tue, 11 Jun 2019 22:04:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: fortran
X-Bugzilla-Version: 9.1.1
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: tkoenig at gcc dot gnu.org
X-Bugzilla-Status: NEW
X-Bugzilla-Resolution:
X-Bugzilla-Priority: P4
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 7.5
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-90744-4-rsmcntF8yR@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-90744-4@http.gcc.gnu.org/bugzilla/>
References: <bug-90744-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2019-06/txt/msg00884.txt.bz2
Content-length: 1171

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90744

--- Comment #8 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
Author: tkoenig
Date: Tue Jun 11 22:04:10 2019
New Revision: 272173

URL: https://gcc.gnu.org/viewcvs?rev=272173&root=gcc&view=rev
Log:
2019-06-11  Thomas Koenig  <tkoenig@gcc.gnu.org>
        Tomáš Trnka  <trnka@scm.com>

        Backport from trunk
        PR fortran/90744
        * trans-types.c (get_formal_from_actual_arglist): Unset typespec
        flags which make no sense for procedures without explicit
        interface.

2019-06-11  Thomas Koenig  <tkoenig@gcc.gnu.org>
        Tomáš Trnka  <trnka@scm.com>

        Backport from trunk
        PR fortran/90744
        * gfortran.dg/deferred_character_33.f90: New test.
        * gfortran.dg/deferred_character_33a.f90: New test.


Added:
    branches/gcc-9-branch/gcc/testsuite/gfortran.dg/deferred_character_33.f90
    branches/gcc-9-branch/gcc/testsuite/gfortran.dg/deferred_character_33a.f90
Modified:
    branches/gcc-9-branch/gcc/fortran/ChangeLog
    branches/gcc-9-branch/gcc/fortran/trans-types.c
    branches/gcc-9-branch/gcc/testsuite/ChangeLog
>From gcc-bugs-return-646370-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Jun 11 22:26:51 2019
Return-Path: <gcc-bugs-return-646370-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 108606 invoked by alias); 11 Jun 2019 22:26:51 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 108538 invoked by uid 48); 11 Jun 2019 22:26:48 -0000
From: "segher at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/90513] asm thunks do not work on PowerPC64/VxWorks (kernel mode)
Date: Tue, 11 Jun 2019 22:26:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: target
X-Bugzilla-Version: 10.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: segher at gcc dot gnu.org
X-Bugzilla-Status: NEW
X-Bugzilla-Resolution:
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-90513-4-HiGknu6GaU@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-90513-4@http.gcc.gnu.org/bugzilla/>
References: <bug-90513-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2019-06/txt/msg00885.txt.bz2
Content-length: 289

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90513

--- Comment #19 from Segher Boessenkool <segher at gcc dot gnu.org> ---
Also, please post proper patches, to the gcc-patches mailing list, as
detailed in <https://gcc.gnu.org/contribute.html>, if you want those
patches to be approved.
>From gcc-bugs-return-646371-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Jun 11 22:31:48 2019
Return-Path: <gcc-bugs-return-646371-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 111893 invoked by alias); 11 Jun 2019 22:31:48 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 111885 invoked by uid 89); 11 Jun 2019 22:31:48 -0000
Authentication-Results: sourceware.org; auth=none
X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=H*Ad:U*amodra, HX-Languages-Length:377
X-HELO: gate.crashing.org
Received: from gate.crashing.org (HELO gate.crashing.org) (63.228.1.57) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 11 Jun 2019 22:31:46 +0000
Received: from gate.crashing.org (localhost.localdomain [127.0.0.1])	by gate.crashing.org (8.14.1/8.14.1) with ESMTP id x5BMViYE020798;	Tue, 11 Jun 2019 17:31:44 -0500
Received: (from segher@localhost)	by gate.crashing.org (8.14.1/8.14.1/Submit) id x5BMVikW020797;	Tue, 11 Jun 2019 17:31:44 -0500
Date: Tue, 11 Jun 2019 22:31:00 -0000
From: Segher Boessenkool <segher@kernel.crashing.org>
To: Umesh Kalappa <umesh.kalappa0@gmail.com>
Cc: Alan Modra <amodra@gmail.com>, gcc-bugs@gcc.gnu.org
Subject: Re: [Bug target/90513] asm thunks do not work on PowerPC64/VxWorks (kernel mode)
Message-ID: <20190611223144.GL31586@gate.crashing.org>
References: <bug-90513-4@http.gcc.gnu.org/bugzilla/> <bug-90513-4-zLYWHPccwo@http.gcc.gnu.org/bugzilla/> <CAGfacvSx4y6J8SRtBYqyGJ+KQxeX-jfoFKG-SS8OiCBoCc=Vxw@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <CAGfacvSx4y6J8SRtBYqyGJ+KQxeX-jfoFKG-SS8OiCBoCc=Vxw@mail.gmail.com>
User-Agent: Mutt/1.4.2.3i
X-IsSubscribed: yes
X-SW-Source: 2019-06/txt/msg00886.txt.bz2
Content-length: 300

On Tue, Jun 11, 2019 at 10:25:58PM +0530, Umesh Kalappa wrote:
> We would like to know comments on the  below  proposed change ?

As I said in the PR, this is not a proper patch.  Also, like Eric says
there, it does not do the right thing for many configurations.

Fix the loader, instead?


Segher


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug middle-end/90844] missing -Wmaybe-uninitialized with -flto and optimization
  2019-06-11 21:03 [Bug c/90844] New: Another case of missing use of uninitialized variable warning subscriptions-gnu at vsbe dot com
@ 2021-04-15 22:55 ` msebor at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-04-15 22:55 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90844

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |msebor at gcc dot gnu.org
            Summary|Another case of missing use |missing
                   |of uninitialized variable   |-Wmaybe-uninitialized with
                   |warning (inlining, CCP)     |-flto and optimization
   Last reconfirmed|2019-06-12 00:00:00         |2021-4-15
      Known to fail|                            |10.2.0, 11.0, 8.3.0, 9.3.0

--- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> ---
The late uninit pass doesn't run with -flto; all that runs is the early
uninitialized pass and it disables the "conditional" -Wmaybe-uninitialized when
optimization is enabled:

static unsigned int
execute_early_warn_uninitialized (void)
{
  /* Currently, this pass runs always but
     execute_late_warn_uninitialized only runs with optimization.  With
     optimization we want to warn about possible uninitialized as late
     as possible, thus don't do it here.  However, without
     optimization we need to warn here about "may be uninitialized".  */
  calculate_dominance_info (CDI_POST_DOMINATORS);

  warn_uninitialized_vars (/*warn_maybe_uninitialized=*/!optimize);
                                                        ^^^^^^^^^
Changing that like so lets the warning do its thing even with -flto:

@@ -3086,7 +3079,8 @@ execute_early_warn_uninitialized (void)
      optimization we need to warn here about "may be uninitialized".  */
   calculate_dominance_info (CDI_POST_DOMINATORS);

-  warn_uninitialized_vars (/*warn_maybe_uninitialized=*/!optimize);
+  bool wmaybe_uninit = !optimize || flag_lto;
+  warn_uninitialized_vars (wmaybe_uninit);

   /* Post-dominator information cannot be reliably updated.  Free it
      after the use.  */

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-04-15 22:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-11 21:03 [Bug c/90844] New: Another case of missing use of uninitialized variable warning subscriptions-gnu at vsbe dot com
2021-04-15 22:55 ` [Bug middle-end/90844] missing -Wmaybe-uninitialized with -flto and optimization msebor at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).