public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug sanitizer/66908] New: Uninitialized variable when compiled with UBsan
@ 2015-07-17 10:48 m.guseva at samsung dot com
  2015-07-20 18:20 ` [Bug sanitizer/66908] " y.gribov at samsung dot com
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: m.guseva at samsung dot com @ 2015-07-17 10:48 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66908

            Bug ID: 66908
           Summary: Uninitialized variable when compiled with UBsan
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: sanitizer
          Assignee: unassigned at gcc dot gnu.org
          Reporter: m.guseva at samsung dot com
                CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org,
                    jakub at gcc dot gnu.org, kcc at gcc dot gnu.org
  Target Milestone: ---

Created attachment 36002
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36002&action=edit
Reproducer

When compiled with "-fsanitize=shift,bounds" the gcc reports that "i" variable
maybe uninitialized:
gcc  -O2  -fsanitize=shift,bounds -std=gnu89 -Werror=maybe-uninitialized -c
testcase.c
testcase.c: In function Б─≤fooБ─≥:
testcase.c:21:36: error: Б─≤i.1Б─≥ may be used uninitialized in this function
[-Werror=maybe-uninitialized]
     res[i] = ((data->scale[i] + tab[i]) << mult);

It's not true in original source code however in produced gimple the "i.1" is
initialized in <D.3009> block but may be used in block <D.3010>:
 23   if (mult.0 > 31) goto <D.3009>; else goto <D.3010>;
 24   <D.3009>:
 25   D.3011 = (unsigned long) mult.0;
 26   D.3012 = data->scale[i];
 27   D.3013 = (int) D.3012;
 28   i.1 = i;
 29   UBSAN_BOUNDS (0B, i.1, 21);
 30   D.3015 = tab[i.1];
 31   D.3016 = (int) D.3015;
 32   D.3017 = D.3013 + D.3016;
 33   D.3018 = (unsigned long) D.3017;
 34   __builtin___ubsan_handle_shift_out_of_bounds (&*.Lubsan_data0, D.3018,
D.3011);
 35   goto <D.3019>;
 36   <D.3010>:
 37   <D.3019>:
 38   D.3020 = (long unsigned int) i;
 39   D.3021 = D.3020 * 4;
 40   D.3022 = res + D.3021;
 41   D.3012 = data->scale[i];
 42   D.3013 = (int) D.3012;
 43   UBSAN_BOUNDS (0B, i.1, 21);

Discovered in gcc 4.9.2, reproduced on trunk with "-std=gnu89".
>From gcc-bugs-return-492619-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Fri Jul 17 10:54:57 2015
Return-Path: <gcc-bugs-return-492619-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 79961 invoked by alias); 17 Jul 2015 10:54:56 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 79905 invoked by uid 48); 17 Jul 2015 10:54:52 -0000
From: "davmac at davmac dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug inline-asm/30527] Use of input/output operands in __asm__ templates not fully documented
Date: Fri, 17 Jul 2015 10:54:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: inline-asm
X-Bugzilla-Version: 4.1.1
X-Bugzilla-Keywords: documentation
X-Bugzilla-Severity: normal
X-Bugzilla-Who: davmac at davmac dot org
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: <bug-30527-4-dYAffGpE50@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-30527-4@http.gcc.gnu.org/bugzilla/>
References: <bug-30527-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-07/txt/msg01509.txt.bz2
Content-length: 304

https://gcc.gnu.org/bugzilla/show_bug.cgi?id0527

--- Comment #4 from Davin McCall <davmac at davmac dot org> ---
I recently stumbled across section 6.43.2.7 of the manual, which does in fact
document the operand modifiers for (and only for) x86. Modifiers for other
architectures are not documented.


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2015-08-11 15:47 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-17 10:48 [Bug sanitizer/66908] New: Uninitialized variable when compiled with UBsan m.guseva at samsung dot com
2015-07-20 18:20 ` [Bug sanitizer/66908] " y.gribov at samsung dot com
2015-07-21 12:34 ` mpolacek at gcc dot gnu.org
2015-07-21 13:48 ` mpolacek at gcc dot gnu.org
2015-07-21 14:40 ` mpolacek at gcc dot gnu.org
2015-07-22  7:38 ` chefmax at gcc dot gnu.org
2015-07-22  8:21 ` mpolacek at gcc dot gnu.org
2015-07-22 12:07 ` mpolacek at gcc dot gnu.org
2015-07-22 12:40 ` mpolacek at gcc dot gnu.org
2015-07-22 14:36 ` mpolacek at gcc dot gnu.org
2015-07-22 15:03 ` chefmax at gcc dot gnu.org
2015-07-22 15:26 ` mpolacek at gcc dot gnu.org
2015-07-22 17:47 ` chefmax at gcc dot gnu.org
2015-07-23 13:56 ` mpolacek at gcc dot gnu.org
2015-07-23 13:58 ` chefmax at gcc dot gnu.org
2015-08-11 15:47 ` mpolacek at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).