From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4126A3858CDB; Thu, 2 Mar 2023 21:46:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4126A3858CDB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677793618; bh=nfxgbYOG3GeMl7x0rTEhgDUA2sX2CopsQmTyYsqCE8c=; h=From:To:Subject:Date:In-Reply-To:References:From; b=yy4LNBizIarR0SH3UlhzNwV1wznkWEneWAY2SaLtDpsxyGyTusNcXTo+3m+pvzw1c DwGsb5Fzxvge5LIdCJ40ERD9JCi7zaXE0ipNOzsQENE9XDxMnJHsHGFqKLh8WNCQe6 toAue++37+R87AYP79pr0t/q+PN4wlEyatHxsdIg= From: "dmalcolm at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug analyzer/108968] fanalyzer false positive with the uninitalised-ness of the stack pointer Date: Thu, 02 Mar 2023 21:46:58 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: analyzer X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: dmalcolm at gcc dot gnu.org X-Bugzilla-Status: WAITING X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: dmalcolm 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D108968 --- Comment #16 from David Malcolm --- Minimized version of attachment 54572: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ struct cpu_info { /* [...snip...] */ struct vcpu *current_vcpu; /* [...snip...] */ }; struct vcpu { /* [...snip...] */ struct domain *domain; /* [...snip...] */ }; static __inline__ struct cpu_info *get_cpu_info_from_stack(unsigned long sp) { return (struct cpu_info *)((sp | ((((1L) << 12) << 3) - 1)) + 1) - 1; } static __inline__ struct cpu_info *get_cpu_info(void) { register unsigned long sp asm("rsp"); return get_cpu_info_from_stack(sp); } void foo(char *other) { char *ptr =3D ((void*)0); if ( ((get_cpu_info()->current_vcpu))->domain ) ptr =3D other; asm volatile ("cmc"); if ( ((get_cpu_info()->current_vcpu))->domain ) ptr[0] =3D ~ptr[0]; } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~= ~=