From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 35F843851C0C; Mon, 19 Apr 2021 18:57:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 35F843851C0C From: "muecker at gwdg dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/99797] accessing uninitialized automatic variables Date: Mon, 19 Apr 2021 18:57:46 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: muecker at gwdg dot de 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: Message-ID: In-Reply-To: References: 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, 19 Apr 2021 18:57:46 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99797 --- Comment #11 from Martin Uecker --- (In reply to Ivan Sorokin from comment #10) ... > > is a bug if this choice is unreasonable and does not serve its users we= ll. >=20 > Do you have some specific proposal in mind? >=20 > Currently a user has these 5 options: > 1. Using -O0 suppressing optimizations. > 2. Using -fno-tree-ccp suppressing this specific optimization. Optimizations are important, so this is not really an option. > 3. Using -Wall and relying on warnings. It is not clear to me that this fully addresses the problem. GCC does not w= arn about all possible accesses to uninitialized variables. > 4. (in theory) Using static analyzer -fanalyzer. It doesn't detect this e= rror > at the moment, but I believe can be taught detecting this. This may be helpful. > 5. Using dynamic analyzer like valgrind. This is too expensive for production and also only useful for limited testi= ng. > It seems that you find existing options insufficient and want another one. I want the optimizer to assume that uninitialized variables have an unknown= but fixed value. Then one could still optimize almost as well *and* get analyza= ble and more benign behavior even when uninitialized variables are accessed. Optimizers already know how to deal with variables of unknown content, so t= his should be fairly easy to implement (maybe I will try). I would also like something such as -fsanitize=3Dundefined which detects for uninitialized variables at run-time. Best, Martin=