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 ESMTPS id CBA88385E012 for ; Wed, 12 Oct 2022 13:47:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CBA88385E012 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665582421; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=b3wvOrSE6mNnCyBaZZN9wffHwqFo1/6M4ux7idMt3rA=; b=VruXs6VKLuF1ICz/IEyUbrzpAbIsKYjyfnl1+cNyO+IMjfePrqbNwHTa75B2HwZA4bGrf1 uyBxJqIJ2xZ2lw6y9WHthjiGj6xA8h0FjDBN3KBetWuFcIxLQFeWyVcdFoomuwMoxr2mVC Dc+KbGObz93NxPlHf0FRceiCkQ/L9CU= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-42-dlmEF8T8M1q5XidkNp_T9Q-1; Wed, 12 Oct 2022 09:46:55 -0400 X-MC-Unique: dlmEF8T8M1q5XidkNp_T9Q-1 Received: by mail-qk1-f198.google.com with SMTP id i11-20020a05620a404b00b006eeb0791c1aso135636qko.10 for ; Wed, 12 Oct 2022 06:46:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:content-transfer-encoding:date:to:from :subject:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=b3wvOrSE6mNnCyBaZZN9wffHwqFo1/6M4ux7idMt3rA=; b=Fgyc7yeAh1+I8COb6O9uH8oDzlox6nrs26PZNmRCeh5mGEBzwF/0vmYZVFiwE1T+/z kEHFZzJP6A5WeE/lyQ6OssUWSOUdPUX8rSxfYgCM0yc3VNA6ccEQBnIXIRQwscFBb6RA FaT5IgSjOUPqHoYqziOPBimp3kD09dKO99JScZGUG9ER982lauNhKiWwU8JLOUcCDM33 b3Ks+p0KBxpMFsjDswqK4cT5nAHumTaaF36mGyiG/Cs4l98+ldMgMbWqrnR0BLoY4pdv AejQdfozbA/k5JQ7bcIUDyMveL2nhAnYUufoYYScgFF+UAVl0Kl0YIlq85v7UN5o7toA 5NBw== X-Gm-Message-State: ACrzQf1uIqHlPX+trXhY7fSRIsdpRsOx85gdIFpO84lWcd/G2FUIwOJh /6fXXk7ZClPWQibgVTzJlse81vjgGz5grfOjcif+1ovBFthDFjrzwbF+oVEGtPYIlMZufhXoD1S 2hXTNvYrWtdxHQliHjxD9hrftJlMWsSuKCB5cXK0dsrvsxsgeS85z9VVJpaThDk2z X-Received: by 2002:a05:6214:ca8:b0:4b1:85c1:4de6 with SMTP id s8-20020a0562140ca800b004b185c14de6mr23352692qvs.13.1665582414526; Wed, 12 Oct 2022 06:46:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4RbwWYCKU027x0EyZR6ZIxBaHkXonHxLBx7YjBXqGbGjLdm9u05sYXIZ41lse/PP6hlX6wfg== X-Received: by 2002:a05:6214:ca8:b0:4b1:85c1:4de6 with SMTP id s8-20020a0562140ca800b004b185c14de6mr23352664qvs.13.1665582414109; Wed, 12 Oct 2022 06:46:54 -0700 (PDT) Received: from t14s.localdomain (c-73-69-212-193.hsd1.ma.comcast.net. [73.69.212.193]) by smtp.gmail.com with ESMTPSA id a18-20020a05622a02d200b0039543f89109sm13511061qtx.96.2022.10.12.06.46.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Oct 2022 06:46:53 -0700 (PDT) Message-ID: <575b023befd11f896b1f1816b757e4f55cb0b0a3.camel@redhat.com> Subject: Question about Fortran bounds and -Wanalyzer-use-of-uninitialized-value From: David Malcolm To: fortran@gcc.gnu.org Date: Wed, 12 Oct 2022 09:46:52 -0400 User-Agent: Evolution 3.44.4 (3.44.4-1.fc36) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-5.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Sorry in advance if this is a silly question; my knowledge of Fortran is next to nothing, I'm afraid. PR analyzer/107210 reports an ICE in -fanalyzer on this reproducer: ! { dg-additional-options "-O1" } subroutine check_int (j) INTEGER(4) :: i, ia(5), ib(5,4), ip, ipa(:) target :: ib POINTER :: ip, ipa logical :: l(5) l =3D (/ sizeof(i) =3D=3D 4, sizeof(ia) =3D=3D 20, sizeof(ib) =3D=3D 80, = & sizeof(ip) =3D=3D 4, sizeof(ipa) =3D=3D 8 /) ! { dg-warning "use of = uninitialized value" } if (any(.not.l)) STOP 4 end subroutine check_int The fix for the ICE is trivial (a missing check that tree_fits_uhwi_p), but after the fix, I see these warnings from the analyzer: 10 | sizeof(ip) =3D=3D 4, sizeof(ipa) =3D=3D 8 /) | ^ Warning: use of uninitialized value =E2=80=98ipa.dim[0].ubound=E2=80=99 [CW= E-457] [-Wanalyzer-use-of-uninitialized-value] =E2=80=98check_int=E2=80=99: events 1-3 | | 4 | INTEGER(4) :: i, ia(5), ib(5,4), ip, ipa(:) | | ^ | | | | | (1) region created= on stack here | | (2) capacity: 8 by= tes |...... | 10 | sizeof(ip) =3D=3D 4, sizeof(ipa) =3D=3D 8 /) | | ~ =20 | | | | | (3) use of uninitial= ized value =E2=80=98ipa.dim[0].ubound=E2=80=99 here | ../../src/gcc/testsuite/gfortran.dg/analyzer/pr107210.f90:10:43: 10 | sizeof(ip) =3D=3D 4, sizeof(ipa) =3D=3D 8 /) | ^ Warning: use of uninitialized value =E2=80=98ipa.dim[0].lbound=E2=80=99 [CW= E-457] [-Wanalyzer-use-of-uninitialized-value] =E2=80=98check_int=E2=80=99: events 1-3 | | 4 | INTEGER(4) :: i, ia(5), ib(5,4), ip, ipa(:) | | ^ | | | | | (1) region created= on stack here | | (2) capacity: 8 by= tes |...... | 10 | sizeof(ip) =3D=3D 4, sizeof(ipa) =3D=3D 8 /) | | ~ =20 | | | | | (3) use of uninitial= ized value =E2=80=98ipa.dim[0].lbound=E2=80=99 here | The gimple in question is: __attribute__((fn spec (". w "))) void check_int (integer(kind=3D4) & restrict j) { integer(kind=3D8) ipa$dim$0$lbound; integer(kind=3D8) ipa$dim$0$ubound; logical(kind=3D4) A.1[5]; logical(kind=3D4) l[5]; integer(kind=3D8) _1; logical(kind=3D4) _3; logical(kind=3D4) _4; integer(kind=3D8) _5; logical(kind=3D4) _6; integer(kind=3D8) S.5_7; logical(kind=3D4) test.6_8; integer(kind=3D8) S.7_9; integer(kind=3D8) S.5_16; integer(kind=3D8) S.7_18; [local count: 178992760]: MEM [(c_char * {ref-all})&A.1] =3D 0x100000001000000010000000= 1; _1 =3D ipa$dim$0$ubound_2(D) - ipa$dim$0$lbound_12(D); _3 =3D _1 =3D=3D 1; MEM[(logical(kind=3D4) *)&A.1 + 16B] =3D _3; [...snip...] where the analyzer is complaining about this gimple statement: _1 =3D ipa$dim$0$ubound_2(D) - ipa$dim$0$lbound_12(D); where both: ipa$dim$0$ubound_2(D) and: ipa$dim$0$lbound_12(D) are considered by it to be uninitialized. Is the analyzer correct here, or is there an aspect of Fortan and/or gimple that I'm missing? Thanks Dave