public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug sanitizer/85777] [8/9/10 Regression] -fsanitize=undefined makes a -Wmaybe-uninitialized warning disappear
       [not found] <bug-85777-4@http.gcc.gnu.org/bugzilla/>
@ 2020-03-11 14:39 ` vincent-gcc at vinc17 dot net
  2021-04-05 22:05 ` [Bug sanitizer/85777] [8/9/10/11 " msebor at gcc dot gnu.org
  2021-04-06 21:38 ` vincent-gcc at vinc17 dot net
  2 siblings, 0 replies; 3+ messages in thread
From: vincent-gcc at vinc17 dot net @ 2020-03-11 14:39 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #14 from Vincent Lefèvre <vincent-gcc at vinc17 dot net> ---
(In reply to Vincent Lefèvre from comment #1)
> I've cleaned up the testcase:
> 
> int d;
> int h(void);
> void e(void)
> {
>   int f[2];
>   int g = 0;
>   if (d)
>     g++;
>   if (d == 1)
>     f[g++] = 2;
>   (void) (f[0] || (g && h()));
> }
[...]
> but
> 
> cventin% gcc-snapshot -Werror=uninitialized -Werror=maybe-uninitialized -O2
> -c file.c -fsanitize=undefined
> cventin%

I now get a warning/error as expected:

file.c: In function ‘e’:
file.c:11:12: error: ‘f[0]’ may be used uninitialized in this function
[-Werror=maybe-uninitialized]
   11 |   (void) (f[0] || (g && h()));
      |           ~^~~
cc1: some warnings being treated as errors

with gcc-10 (Debian 10-20200304-1) 10.0.1 20200304 (experimental) [master
revision 0b0908c1f27:cb0a7e0ca53:94f7d7ec6ebef49a50da777fd71db3d03ee03aa0].

But here's a new testcase:

int foo1 (void);
int foo2 (int);

int bar (void)
{
  int i;
  auto void cf (int *t) { foo2 (i); }
  int t __attribute__ ((cleanup (cf)));

  t = 0;

  if (foo1 ())
    i = foo1 ();

  i = ! foo1 () || i;
  foo2 (i);

  return 0;
}

What's strange is that if I change the line

  i = ! foo1 () || i;

to

  i = foo1 () || i;

(i.e. if I just remove the "!", though this shouldn't change anything since GCC
does not have any knowledge on what foo1 returns), I get an error as expected:

uninit-test.c: In function ‘bar’:
uninit-test.c:15:15: error: ‘FRAME.1.i’ may be used uninitialized in this
function [-Werror=maybe-uninitialized]
   15 |   i = foo1 () || i;
      |       ~~~~~~~~^~~~
cc1: some warnings being treated as errors

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

* [Bug sanitizer/85777] [8/9/10/11 Regression] -fsanitize=undefined makes a -Wmaybe-uninitialized warning disappear
       [not found] <bug-85777-4@http.gcc.gnu.org/bugzilla/>
  2020-03-11 14:39 ` [Bug sanitizer/85777] [8/9/10 Regression] -fsanitize=undefined makes a -Wmaybe-uninitialized warning disappear vincent-gcc at vinc17 dot net
@ 2021-04-05 22:05 ` msebor at gcc dot gnu.org
  2021-04-06 21:38 ` vincent-gcc at vinc17 dot net
  2 siblings, 0 replies; 3+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-04-05 22:05 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |msebor at gcc dot gnu.org
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #15 from Martin Sebor <msebor at gcc dot gnu.org> ---
Based on comment #14 it sounds like the originally reported problem has been
resolved.  The test case in that comment doesn't trigger a warning in GCC 11
one way or the other, but also doesn't seem related to the original problem
report (if what you see is not what you  expect please open a separate bug for
just that problem.)

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

* [Bug sanitizer/85777] [8/9/10/11 Regression] -fsanitize=undefined makes a -Wmaybe-uninitialized warning disappear
       [not found] <bug-85777-4@http.gcc.gnu.org/bugzilla/>
  2020-03-11 14:39 ` [Bug sanitizer/85777] [8/9/10 Regression] -fsanitize=undefined makes a -Wmaybe-uninitialized warning disappear vincent-gcc at vinc17 dot net
  2021-04-05 22:05 ` [Bug sanitizer/85777] [8/9/10/11 " msebor at gcc dot gnu.org
@ 2021-04-06 21:38 ` vincent-gcc at vinc17 dot net
  2 siblings, 0 replies; 3+ messages in thread
From: vincent-gcc at vinc17 dot net @ 2021-04-06 21:38 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #16 from Vincent Lefèvre <vincent-gcc at vinc17 dot net> ---
Well, concerning the initial testcase (and its cleaned-up version), the issue
is either fixed or hidden by another bug, which I've just reported: PR99944.
Indeed, I now get a maybe-uninitialized warning, but on f (which is incorrect)
instead of f[0].

Concerning the other testcase from Comment 14, I was wrong:
-fsanitize=undefined actually has the opposite effect, so that this is a
different bug, which I've reported: PR99945.

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

end of thread, other threads:[~2021-04-06 21:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-85777-4@http.gcc.gnu.org/bugzilla/>
2020-03-11 14:39 ` [Bug sanitizer/85777] [8/9/10 Regression] -fsanitize=undefined makes a -Wmaybe-uninitialized warning disappear vincent-gcc at vinc17 dot net
2021-04-05 22:05 ` [Bug sanitizer/85777] [8/9/10/11 " msebor at gcc dot gnu.org
2021-04-06 21:38 ` vincent-gcc at vinc17 dot net

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).