public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/98508] New: Sanitizer disable -Wall and -Wextra
@ 2021-01-04  8:31 awdawdawdawq123123 at gmx dot de
  2021-01-04  8:51 ` [Bug c++/98508] " jakub at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: awdawdawdawq123123 at gmx dot de @ 2021-01-04  8:31 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 98508
           Summary: Sanitizer disable -Wall and -Wextra
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: awdawdawdawq123123 at gmx dot de
  Target Milestone: ---

Created attachment 49871
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49871&action=edit
source file

1.cpp:
```
struct S
{
    int a;
};

int main()
{
    S s = S(s);
}
```

Compiling this by calling 

g++ -Wall -Wextra  1.cpp

yields the warning:
```
1.cpp: In function ‘int main()’:
1.cpp:8:7: warning: ‘s’ is used uninitialized in this function
[-Wuninitialized]
    8 |     S s = S(s);
      |       ^
```
as expected. But when additionally using Sanitizers the call

g++ -Wall -Wextra  -fsanitize=address,undefined 1.cpp

yields no warnings. 
Attached is the source file.

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

* [Bug c++/98508] Sanitizer disable -Wall and -Wextra
  2021-01-04  8:31 [Bug c++/98508] New: Sanitizer disable -Wall and -Wextra awdawdawdawq123123 at gmx dot de
@ 2021-01-04  8:51 ` jakub at gcc dot gnu.org
  2021-01-04  8:59 ` awdawdawdawq123123 at gmx dot de
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-01-04  8:51 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
-fsanitize= doesn't disable the warnings, but the added runtime instrumentation
makes some warning disappear and other warnings to appear (e.g. because the
instrumentation prevents some optimizations).

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

* [Bug c++/98508] Sanitizer disable -Wall and -Wextra
  2021-01-04  8:31 [Bug c++/98508] New: Sanitizer disable -Wall and -Wextra awdawdawdawq123123 at gmx dot de
  2021-01-04  8:51 ` [Bug c++/98508] " jakub at gcc dot gnu.org
@ 2021-01-04  8:59 ` awdawdawdawq123123 at gmx dot de
  2021-01-05 18:46 ` [Bug middle-end/98508] " msebor at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: awdawdawdawq123123 at gmx dot de @ 2021-01-04  8:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Joerg <awdawdawdawq123123 at gmx dot de> ---
Oh okay. Is it possible to prevent that from happening?

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

* [Bug middle-end/98508] Sanitizer disable -Wall and -Wextra
  2021-01-04  8:31 [Bug c++/98508] New: Sanitizer disable -Wall and -Wextra awdawdawdawq123123 at gmx dot de
  2021-01-04  8:51 ` [Bug c++/98508] " jakub at gcc dot gnu.org
  2021-01-04  8:59 ` awdawdawdawq123123 at gmx dot de
@ 2021-01-05 18:46 ` msebor at gcc dot gnu.org
  2021-01-05 19:00 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-01-05 18:46 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
                 CC|                            |msebor at gcc dot gnu.org
          Component|c++                         |middle-end
             Blocks|                            |24639
   Last reconfirmed|                            |2021-01-05

--- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> ---
It's possible (and obviously desirable) but difficult in general, which is why
it hasn't been done yet.

But in this case it shouldn't be hard: the warning is suppressed because the
code finds the ASAN_MARK (UNPOISON, &s, 4); call in the IL below, and treats it
like any other pass-by-reference call: it assumes that it might write to s and
thus initialize it.  The "fix" is simple: teach the warning that the .ASAN
directive doesn't do that.

int main ()
{
  int D.2825;

  {
    struct S s;

    try
      {
        .ASAN_MARK (UNPOISON, &s, 4);
        s = s;
      }
    finally
      {
        .ASAN_MARK (POISON, &s, 4);
      }
  }
  D.2825 = 0;
  return D.2825;
}


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=24639
[Bug 24639] [meta-bug] bug to track all Wuninitialized issues

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

* [Bug middle-end/98508] Sanitizer disable -Wall and -Wextra
  2021-01-04  8:31 [Bug c++/98508] New: Sanitizer disable -Wall and -Wextra awdawdawdawq123123 at gmx dot de
                   ` (2 preceding siblings ...)
  2021-01-05 18:46 ` [Bug middle-end/98508] " msebor at gcc dot gnu.org
@ 2021-01-05 19:00 ` jakub at gcc dot gnu.org
  2021-01-05 20:02 ` msebor at gcc dot gnu.org
  2021-04-16 22:32 ` msebor at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-01-05 19:00 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
It is not simple at all.  While the ifns don't modify the references variable,
they do modify the corresponding shadow memory, which is something GCC aliasing
oracle doesn't track at all, so by supplying detailed fnspec about the ifns
there is a very high risk it will start miscompiling things.
I have tried it in the past, and it just didn't work.

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

* [Bug middle-end/98508] Sanitizer disable -Wall and -Wextra
  2021-01-04  8:31 [Bug c++/98508] New: Sanitizer disable -Wall and -Wextra awdawdawdawq123123 at gmx dot de
                   ` (3 preceding siblings ...)
  2021-01-05 19:00 ` jakub at gcc dot gnu.org
@ 2021-01-05 20:02 ` msebor at gcc dot gnu.org
  2021-04-16 22:32 ` msebor at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-01-05 20:02 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Martin Sebor <msebor at gcc dot gnu.org> ---
There's no need to change the fn spec.  The simple (and safe) solution to this
request is to check calls to see if they're to IFN_ASAN_MARK, like this:

diff --git a/gcc/tree-ssa-uninit.c b/gcc/tree-ssa-uninit.c
index 516a7bd2c99..c3718f96b55 100644
--- a/gcc/tree-ssa-uninit.c
+++ b/gcc/tree-ssa-uninit.c
@@ -209,6 +209,11 @@ check_defs (ao_ref *ref, tree vdef, void *data_)
 {
   check_defs_data *data = (check_defs_data *)data_;
   gimple *def_stmt = SSA_NAME_DEF_STMT (vdef);
+  if (is_gimple_call (def_stmt)
+      && gimple_call_internal_p (def_stmt)
+      && gimple_call_internal_fn (def_stmt) == IFN_ASAN_MARK)
+    return false;
+
   /* If this is a clobber then if it is not a kill walk past it.  */
   if (gimple_clobber_p (def_stmt))
     {

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

* [Bug middle-end/98508] Sanitizer disable -Wall and -Wextra
  2021-01-04  8:31 [Bug c++/98508] New: Sanitizer disable -Wall and -Wextra awdawdawdawq123123 at gmx dot de
                   ` (4 preceding siblings ...)
  2021-01-05 20:02 ` msebor at gcc dot gnu.org
@ 2021-04-16 22:32 ` msebor at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-04-16 22:32 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |DUPLICATE
             Status|NEW                         |RESOLVED

--- Comment #6 from Martin Sebor <msebor at gcc dot gnu.org> ---
Resolving as a duplicate of pr93100.

*** This bug has been marked as a duplicate of bug 93100 ***

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

end of thread, other threads:[~2021-04-16 22:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-04  8:31 [Bug c++/98508] New: Sanitizer disable -Wall and -Wextra awdawdawdawq123123 at gmx dot de
2021-01-04  8:51 ` [Bug c++/98508] " jakub at gcc dot gnu.org
2021-01-04  8:59 ` awdawdawdawq123123 at gmx dot de
2021-01-05 18:46 ` [Bug middle-end/98508] " msebor at gcc dot gnu.org
2021-01-05 19:00 ` jakub at gcc dot gnu.org
2021-01-05 20:02 ` msebor at gcc dot gnu.org
2021-04-16 22:32 ` msebor 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).