From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id F38C33851C01; Mon, 22 Jun 2020 12:53:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F38C33851C01 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1592830427; bh=XoG/Lch4eZrWJJsFC5pql9vFObu+nIjluwa9XX/lwoM=; h=From:To:Subject:Date:From; b=Dm8weWa/fw5gXD7aLv1DjWSmYWKaQTs9/vE9EVrDOii0A7qQe64Z+1Hvxe3rnZ81d k3e86l9H99JNW6cfdFBvLaLvRM0wTw6vA+OOkr8jZyE4QCWXN899PAeRnJGJBSmyLK weUTl4tx2aGZ34VSFqH6YHDnQ16ZtHskLm+cCrrA= From: "ferruh.yigit at intel dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/95818] New: wrong "used uninitialized" warning Date: Mon, 22 Jun 2020 12:53:46 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: ferruh.yigit at intel dot com X-Bugzilla-Status: UNCONFIRMED 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Jun 2020 12:53:47 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95818 Bug ID: 95818 Summary: wrong "used uninitialized" warning Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: ferruh.yigit at intel dot com Target Milestone: --- gcc (GCC) 11.0.0 20200621 (experimental) Sorry, I couldn't able to reproduce with test code, I will copy-paste the r= eal code that causes the warning hoping it helps. Warning [1] and code that causes it [2], struct in question [3]. As you can see all the fields of the struct has been set before used, so not sure why giving used uninitialized warning. [1] .../drivers/net/iavf/iavf_ethdev.c: In function =E2=80=98iavf_dev_link_upda= te=E2=80=99: .../drivers/net/iavf/iavf_ethdev.c:641:6: error: =E2=80=98new_link=E2=80=99= is used uninitialized [-Werror=3Duninitialized] 641 | if (rte_atomic64_cmpset((uint64_t *)&dev->data->dev_link, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 642 | *(uint64_t *)&dev->data->dev_link, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 643 | *(uint64_t *)&new_link) =3D=3D 0) | ~~~~~~~~~~~~~~~~~~~~~~~ .../drivers/net/iavf/iavf_ethdev.c:596:22: note: =E2=80=98new_link=E2=80=99= declared here 596 | struct rte_eth_link new_link; | ^~~~~~~~ cc1: all warnings being treated as error [2] iavf_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete) { struct rte_eth_link new_link; struct iavf_info *vf =3D IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_priv= ate); /* Only read status info stored in VF, and the info is updated * when receive LINK_CHANGE evnet from PF by Virtchnnl. */ switch (vf->link_speed) { case 10: new_link.link_speed =3D ETH_SPEED_NUM_10M; break; case 100: new_link.link_speed =3D ETH_SPEED_NUM_100M; break; case 1000: new_link.link_speed =3D ETH_SPEED_NUM_1G; break; case 10000: new_link.link_speed =3D ETH_SPEED_NUM_10G; break; case 20000: new_link.link_speed =3D ETH_SPEED_NUM_20G; break; case 25000: new_link.link_speed =3D ETH_SPEED_NUM_25G; break; case 40000: new_link.link_speed =3D ETH_SPEED_NUM_40G; break; case 50000: new_link.link_speed =3D ETH_SPEED_NUM_50G; break; case 100000: new_link.link_speed =3D ETH_SPEED_NUM_100G; break; default: new_link.link_speed =3D ETH_SPEED_NUM_NONE; break; } new_link.link_duplex =3D ETH_LINK_FULL_DUPLEX; new_link.link_status =3D vf->link_up ? ETH_LINK_UP : ETH_LINK_DOWN; new_link.link_autoneg =3D !(dev->data->dev_conf.link_speeds & ETH_LINK_SPEED_FIXED); if (rte_atomic64_cmpset((uint64_t *)&dev->data->dev_link, *(uint64_t *)&dev->data->dev_link, *(uint64_t *)&new_link) =3D=3D 0) return -1; return 0; } [3] struct rte_eth_link { uint32_t link_speed; /**< ETH_SPEED_NUM_ */ uint16_t link_duplex : 1; /**< ETH_LINK_[HALF/FULL]_DUPLEX */ uint16_t link_autoneg : 1; /**< ETH_LINK_[AUTONEG/FIXED] */ uint16_t link_status : 1; /**< ETH_LINK_[DOWN/UP] */ } __rte_aligned(8); /**< aligned for atomic64 read/write */=