From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9C6A23858413; Mon, 5 Feb 2024 14:07:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9C6A23858413 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1707142038; bh=dAUskppwAoMVmFCjhrBSx300YypaauFGoi+LMNuQ4RQ=; h=From:To:Subject:Date:From; b=Pj2dbGnHdKIsu5mc+977iAavNKi8PcejODwltfVefrmJ9j9yKKjybkhokdMJ7Rcy0 IV0XKVXdMspw1ws+ywS+SSV9+s2ztigm0IHMxmOVFNvpC4VX6ya6/M4ZdsHjtcerZM QpxOmgLNLbQL4J9ja9OhVINRxeGZBYcPn4OSRg+I= From: "symbioticfemale at cumallover dot me" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/113769] New: GCC fails to warn of integer being used uninitialized Date: Mon, 05 Feb 2024 14:07:17 +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: 13.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: symbioticfemale at cumallover dot me 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D113769 Bug ID: 113769 Summary: GCC fails to warn of integer being used uninitialized Product: gcc Version: 13.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: symbioticfemale at cumallover dot me Target Milestone: --- // The "used uninitialized" warning is not produced on both GCC and Tiny Compiler. Clang recognizes the error. (-Wall on all compilers). See line comments for further explanation. The latest version of GCC I've tested wit= h is 13.2.1. // Version 1: With printf #include #include #include pthread_rwlock_t necessary_lock =3D PTHREAD_RWLOCK_INITIALIZER; void do_nothing(const void *value); void do_nothing(const void *value) { printf("%p\n",value); // do anything on value other than (void) val= ue } int main(void) { pthread_rwlock_rdlock(&necessary_lock); pthread_rwlock_unlock(&necessary_lock); // Fun fact: remove either the pthread_rwlock_rdlock + pthread_rwlock_unlock, or the printf in do_nothing, and GCC catches the lac= k of initialization uint32_t pos; pos +=3D 1; do_nothing(&pos); printf("%u\n",pos); } // Version 2: Without printf #include #include #include pthread_rwlock_t necessary_lock =3D PTHREAD_RWLOCK_INITIALIZER; void do_nothing(const void *value); void do_nothing(const void *value) { (void) value; } int main(void) { pthread_rwlock_rdlock(&necessary_lock); pthread_rwlock_unlock(&necessary_lock); // Fun fact: remove either the pthread_rwlock_rdlock + pthread_rwlock_unlock, or the do_nothing function call, and GCC catches the lack of initialization. Add a printf after do_nothing and GCC will also cat= ch it. uint32_t pos; pos +=3D 1; do_nothing(&pos); }=