public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/95693] New: Incorrect error from undefined behavior sanitizer
@ 2020-06-16  5:12 gcc-90 at tbilles dot hu
  2020-06-16  6:43 ` [Bug sanitizer/95693] [8/9/10/11 Regression] " rguenth at gcc dot gnu.org
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: gcc-90 at tbilles dot hu @ 2020-06-16  5:12 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 95693
           Summary: Incorrect error from undefined behavior sanitizer
           Product: gcc
           Version: 10.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gcc-90 at tbilles dot hu
  Target Milestone: ---

After upgrading GCC from 7.2 to 10.1 I get a runtime error when using
-fsanitize=undefined. I cannot see anything wrong with the code. It was also
suggested on the gcc-help mailing list that this is a bug in the compiler.
(https://gcc.gnu.org/pipermail/gcc-help/2020-June/139055.html)

The code in question can be found on Compiler Explorer (also pasted at the end
of this description): https://godbolt.org/z/7rAxJj

It shows that different compiler versions behave differently.

Version 10.1 prints "runtime error: reference binding to null pointer of type
'int'" although there is no null pointer in the code, the reference is bound to
a global integer.

There is a comment on line 16 that explicitly defaults the Derived constructor.
If you switch the comment with line 17, both compiler versions run fine without
producing the runtime error although the defaulted constructor should be
exactly the same the user defined one: https://godbolt.org/z/UShm-u

According to Compiler Explorer the incorrect behavior began in GCC 8.x series
and is still present in trunk.

---
int global = 9;

class Payload {
public:
    Payload() : data(global) {}
private:
    int& data;
};

struct Base {
    Payload payload;
};

class Derived : public Base {
public:
    //Derived() = default;
    Derived() : Base() {}

    Payload p;
};

int main()
{
    Derived t;
}

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

* [Bug sanitizer/95693] [8/9/10/11 Regression] Incorrect error from undefined behavior sanitizer
  2020-06-16  5:12 [Bug c++/95693] New: Incorrect error from undefined behavior sanitizer gcc-90 at tbilles dot hu
@ 2020-06-16  6:43 ` rguenth at gcc dot gnu.org
  2020-06-16  6:57 ` marxin at gcc dot gnu.org
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-06-16  6:43 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 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,
                   |                            |marxin at gcc dot gnu.org
      Known to work|                            |7.2.0
           Keywords|                            |wrong-code
   Target Milestone|---                         |8.5
          Component|c++                         |sanitizer
            Summary|Incorrect error from        |[8/9/10/11 Regression]
                   |undefined behavior          |Incorrect error from
                   |sanitizer                   |undefined behavior
                   |                            |sanitizer

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

* [Bug sanitizer/95693] [8/9/10/11 Regression] Incorrect error from undefined behavior sanitizer
  2020-06-16  5:12 [Bug c++/95693] New: Incorrect error from undefined behavior sanitizer gcc-90 at tbilles dot hu
  2020-06-16  6:43 ` [Bug sanitizer/95693] [8/9/10/11 Regression] " rguenth at gcc dot gnu.org
@ 2020-06-16  6:57 ` marxin at gcc dot gnu.org
  2020-06-16  7:24 ` jakub at gcc dot gnu.org
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: marxin at gcc dot gnu.org @ 2020-06-16  6:57 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
                 CC|                            |jason at gcc dot gnu.org,
                   |                            |mpolacek at gcc dot gnu.org,
                   |                            |nathan at gcc dot gnu.org
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2020-06-16

--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Thank you for the report!
The error is newly printed with r8-7149-g2e1a7ecb2d8f1ee3.

Backtrace is here:
g++ pr95693.C -fsanitize=undefined -g && ./a.out 
pr95693.C:17:22: runtime error: reference binding to null pointer of type 'int'
    #0 0x4011fb in Derived::Derived()
/home/marxin/Programming/testcases/pr95693.C:17
    #1 0x401135 in main /home/marxin/Programming/testcases/pr95693.C:24
    #2 0x7ffff7147cc9 in __libc_start_main ../csu/libc-start.c:308
    #3 0x401079 in _start (/home/marxin/Programming/testcases/a.out+0x401079)

I'm not a C++ expert, but it seems to me an invalid code.

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

* [Bug sanitizer/95693] [8/9/10/11 Regression] Incorrect error from undefined behavior sanitizer
  2020-06-16  5:12 [Bug c++/95693] New: Incorrect error from undefined behavior sanitizer gcc-90 at tbilles dot hu
  2020-06-16  6:43 ` [Bug sanitizer/95693] [8/9/10/11 Regression] " rguenth at gcc dot gnu.org
  2020-06-16  6:57 ` marxin at gcc dot gnu.org
@ 2020-06-16  7:24 ` jakub at gcc dot gnu.org
  2020-06-16  8:41 ` redi at gcc dot gnu.org
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-06-16  7:24 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The Derived ctor seems to first perform zero initialization of the base for
some reason and only then calls the Base constructor.  Dunno if that is
required or not, but since Alex' change actually also zeroes the reference. 
And this state before calling the Base is caught by the sanitizer.  So, to me
it looks like a C++ FE problem that it zero initializes it first, or if it
needs to, then it needs to either avoid what Alex' patch is doing (do that only
during error-recovery), or arrange somehow that it will not be sanitized.

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

* [Bug sanitizer/95693] [8/9/10/11 Regression] Incorrect error from undefined behavior sanitizer
  2020-06-16  5:12 [Bug c++/95693] New: Incorrect error from undefined behavior sanitizer gcc-90 at tbilles dot hu
                   ` (2 preceding siblings ...)
  2020-06-16  7:24 ` jakub at gcc dot gnu.org
@ 2020-06-16  8:41 ` redi at gcc dot gnu.org
  2021-01-14  9:02 ` rguenth at gcc dot gnu.org
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: redi at gcc dot gnu.org @ 2020-06-16  8:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Martin Liška from comment #1)
> I'm not a C++ expert, but it seems to me an invalid code.

I don't see anything wrong with the code.

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

* [Bug sanitizer/95693] [8/9/10/11 Regression] Incorrect error from undefined behavior sanitizer
  2020-06-16  5:12 [Bug c++/95693] New: Incorrect error from undefined behavior sanitizer gcc-90 at tbilles dot hu
                   ` (3 preceding siblings ...)
  2020-06-16  8:41 ` redi at gcc dot gnu.org
@ 2021-01-14  9:02 ` rguenth at gcc dot gnu.org
  2021-01-14 12:58 ` nathan at gcc dot gnu.org
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-01-14  9:02 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2

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

* [Bug sanitizer/95693] [8/9/10/11 Regression] Incorrect error from undefined behavior sanitizer
  2020-06-16  5:12 [Bug c++/95693] New: Incorrect error from undefined behavior sanitizer gcc-90 at tbilles dot hu
                   ` (4 preceding siblings ...)
  2021-01-14  9:02 ` rguenth at gcc dot gnu.org
@ 2021-01-14 12:58 ` nathan at gcc dot gnu.org
  2021-01-21 13:50 ` jakub at gcc dot gnu.org
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: nathan at gcc dot gnu.org @ 2021-01-14 12:58 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Nathan Sidwell <nathan at gcc dot gnu.org> ---
there;s no language reason to zero init the base.  It looks to me as if Alex's
change is compensating for a problem in the pic code he cites.  Is that code
trying to make a PIC initializer for something that is not initialized (in
erroneous code)?

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

* [Bug sanitizer/95693] [8/9/10/11 Regression] Incorrect error from undefined behavior sanitizer
  2020-06-16  5:12 [Bug c++/95693] New: Incorrect error from undefined behavior sanitizer gcc-90 at tbilles dot hu
                   ` (5 preceding siblings ...)
  2021-01-14 12:58 ` nathan at gcc dot gnu.org
@ 2021-01-21 13:50 ` jakub at gcc dot gnu.org
  2021-01-22 18:05 ` cvs-commit at gcc dot gnu.org
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-01-21 13:50 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |jakub at gcc dot gnu.org

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 50019
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50019&action=edit
gcc11-pr95693.patch

This untested patch reverts Alex' build_zero_init* change and instead does it
in the caller where we know it is only for error recovery (we've emitted an
error earlier about it).

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

* [Bug sanitizer/95693] [8/9/10/11 Regression] Incorrect error from undefined behavior sanitizer
  2020-06-16  5:12 [Bug c++/95693] New: Incorrect error from undefined behavior sanitizer gcc-90 at tbilles dot hu
                   ` (6 preceding siblings ...)
  2021-01-21 13:50 ` jakub at gcc dot gnu.org
@ 2021-01-22 18:05 ` cvs-commit at gcc dot gnu.org
  2021-01-22 18:06 ` [Bug sanitizer/95693] [8/9/10 " jakub at gcc dot gnu.org
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-01-22 18:05 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:a9ed18295bfc6d69d40af197e059e16622cd94c6

commit r11-6865-ga9ed18295bfc6d69d40af197e059e16622cd94c6
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Fri Jan 22 19:03:23 2021 +0100

    c++: Fix up ubsan false positives on references [PR95693]

    Alex' 2 years old change to build_zero_init_1 to return NULL pointer with
    reference type for references breaks the sanitizers, the assignment of NULL
    to a reference typed member is then instrumented before it is overwritten
    with a non-NULL address later on.
    That change has been done to fix error recovery ICE during
    process_init_constructor_record, where we:
              if (TYPE_REF_P (fldtype))
                {
                  if (complain & tf_error)
                    error ("member %qD is uninitialized reference", field);
                  else
                    return PICFLAG_ERRONEOUS;
                }
    a few lines earlier, but then continue and ICE when build_zero_init returns
    NULL.

    The following patch reverts the build_zero_init_1 change and instead
creates
    the NULL with reference type constants during the error recovery.

    The pr84593.C testcase Alex' change was fixing still works as before.

    2021-01-22  Jakub Jelinek  <jakub@redhat.com>

            PR sanitizer/95693
            * init.c (build_zero_init_1): Revert the 2018-03-06 change to
            return build_zero_cst for reference types.
            * typeck2.c (process_init_constructor_record): Instead call
            build_zero_cst here during error recovery instead of
build_zero_init.

            * g++.dg/ubsan/pr95693.C: New test.

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

* [Bug sanitizer/95693] [8/9/10 Regression] Incorrect error from undefined behavior sanitizer
  2020-06-16  5:12 [Bug c++/95693] New: Incorrect error from undefined behavior sanitizer gcc-90 at tbilles dot hu
                   ` (7 preceding siblings ...)
  2021-01-22 18:05 ` cvs-commit at gcc dot gnu.org
@ 2021-01-22 18:06 ` jakub at gcc dot gnu.org
  2021-01-29 19:19 ` cvs-commit at gcc dot gnu.org
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-01-22 18:06 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[8/9/10/11 Regression]      |[8/9/10 Regression]
                   |Incorrect error from        |Incorrect error from
                   |undefined behavior          |undefined behavior
                   |sanitizer                   |sanitizer

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed on the trunk so far.

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

* [Bug sanitizer/95693] [8/9/10 Regression] Incorrect error from undefined behavior sanitizer
  2020-06-16  5:12 [Bug c++/95693] New: Incorrect error from undefined behavior sanitizer gcc-90 at tbilles dot hu
                   ` (8 preceding siblings ...)
  2021-01-22 18:06 ` [Bug sanitizer/95693] [8/9/10 " jakub at gcc dot gnu.org
@ 2021-01-29 19:19 ` cvs-commit at gcc dot gnu.org
  2021-01-29 19:24 ` [Bug sanitizer/95693] [8/9 " jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-01-29 19:19 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:e5750f847158e7f9bdab770fd9c5fff58c5074d3

commit r10-9318-ge5750f847158e7f9bdab770fd9c5fff58c5074d3
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Fri Jan 22 19:03:23 2021 +0100

    c++: Fix up ubsan false positives on references [PR95693]

    Alex' 2 years old change to build_zero_init_1 to return NULL pointer with
    reference type for references breaks the sanitizers, the assignment of NULL
    to a reference typed member is then instrumented before it is overwritten
    with a non-NULL address later on.
    That change has been done to fix error recovery ICE during
    process_init_constructor_record, where we:
              if (TYPE_REF_P (fldtype))
                {
                  if (complain & tf_error)
                    error ("member %qD is uninitialized reference", field);
                  else
                    return PICFLAG_ERRONEOUS;
                }
    a few lines earlier, but then continue and ICE when build_zero_init returns
    NULL.

    The following patch reverts the build_zero_init_1 change and instead
creates
    the NULL with reference type constants during the error recovery.

    The pr84593.C testcase Alex' change was fixing still works as before.

    2021-01-22  Jakub Jelinek  <jakub@redhat.com>

            PR sanitizer/95693
            * init.c (build_zero_init_1): Revert the 2018-03-06 change to
            return build_zero_cst for reference types.
            * typeck2.c (process_init_constructor_record): Instead call
            build_zero_cst here during error recovery instead of
build_zero_init.

            * g++.dg/ubsan/pr95693.C: New test.

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

* [Bug sanitizer/95693] [8/9 Regression] Incorrect error from undefined behavior sanitizer
  2020-06-16  5:12 [Bug c++/95693] New: Incorrect error from undefined behavior sanitizer gcc-90 at tbilles dot hu
                   ` (9 preceding siblings ...)
  2021-01-29 19:19 ` cvs-commit at gcc dot gnu.org
@ 2021-01-29 19:24 ` jakub at gcc dot gnu.org
  2021-04-20 23:31 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-01-29 19:24 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[8/9/10 Regression]         |[8/9 Regression] Incorrect
                   |Incorrect error from        |error from undefined
                   |undefined behavior          |behavior sanitizer
                   |sanitizer                   |

--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed for 10.3+ too.

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

* [Bug sanitizer/95693] [8/9 Regression] Incorrect error from undefined behavior sanitizer
  2020-06-16  5:12 [Bug c++/95693] New: Incorrect error from undefined behavior sanitizer gcc-90 at tbilles dot hu
                   ` (10 preceding siblings ...)
  2021-01-29 19:24 ` [Bug sanitizer/95693] [8/9 " jakub at gcc dot gnu.org
@ 2021-04-20 23:31 ` cvs-commit at gcc dot gnu.org
  2021-04-22 16:49 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-04-20 23:31 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-9 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:4ccdb3fdbc14102c91b6148bcbe09d0763726ae0

commit r9-9408-g4ccdb3fdbc14102c91b6148bcbe09d0763726ae0
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Fri Jan 22 19:03:23 2021 +0100

    c++: Fix up ubsan false positives on references [PR95693]

    Alex' 2 years old change to build_zero_init_1 to return NULL pointer with
    reference type for references breaks the sanitizers, the assignment of NULL
    to a reference typed member is then instrumented before it is overwritten
    with a non-NULL address later on.
    That change has been done to fix error recovery ICE during
    process_init_constructor_record, where we:
              if (TYPE_REF_P (fldtype))
                {
                  if (complain & tf_error)
                    error ("member %qD is uninitialized reference", field);
                  else
                    return PICFLAG_ERRONEOUS;
                }
    a few lines earlier, but then continue and ICE when build_zero_init returns
    NULL.

    The following patch reverts the build_zero_init_1 change and instead
creates
    the NULL with reference type constants during the error recovery.

    The pr84593.C testcase Alex' change was fixing still works as before.

    2021-01-22  Jakub Jelinek  <jakub@redhat.com>

            PR sanitizer/95693
            * init.c (build_zero_init_1): Revert the 2018-03-06 change to
            return build_zero_cst for reference types.
            * typeck2.c (process_init_constructor_record): Instead call
            build_zero_cst here during error recovery instead of
build_zero_init.

            * g++.dg/ubsan/pr95693.C: New test.

    (cherry picked from commit e5750f847158e7f9bdab770fd9c5fff58c5074d3)

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

* [Bug sanitizer/95693] [8/9 Regression] Incorrect error from undefined behavior sanitizer
  2020-06-16  5:12 [Bug c++/95693] New: Incorrect error from undefined behavior sanitizer gcc-90 at tbilles dot hu
                   ` (11 preceding siblings ...)
  2021-04-20 23:31 ` cvs-commit at gcc dot gnu.org
@ 2021-04-22 16:49 ` cvs-commit at gcc dot gnu.org
  2021-04-22 17:06 ` jakub at gcc dot gnu.org
  2021-04-23 14:14 ` gcc-90 at tbilles dot hu
  14 siblings, 0 replies; 16+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-04-22 16:49 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #11 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-8 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:a3458b238e1297ad7ab6f92ab1a00837f282691a

commit r8-10875-ga3458b238e1297ad7ab6f92ab1a00837f282691a
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Fri Jan 22 19:03:23 2021 +0100

    c++: Fix up ubsan false positives on references [PR95693]

    Alex' 2 years old change to build_zero_init_1 to return NULL pointer with
    reference type for references breaks the sanitizers, the assignment of NULL
    to a reference typed member is then instrumented before it is overwritten
    with a non-NULL address later on.
    That change has been done to fix error recovery ICE during
    process_init_constructor_record, where we:
              if (TYPE_REF_P (fldtype))
                {
                  if (complain & tf_error)
                    error ("member %qD is uninitialized reference", field);
                  else
                    return PICFLAG_ERRONEOUS;
                }
    a few lines earlier, but then continue and ICE when build_zero_init returns
    NULL.

    The following patch reverts the build_zero_init_1 change and instead
creates
    the NULL with reference type constants during the error recovery.

    The pr84593.C testcase Alex' change was fixing still works as before.

    2021-01-22  Jakub Jelinek  <jakub@redhat.com>

            PR sanitizer/95693
            * init.c (build_zero_init_1): Revert the 2018-03-06 change to
            return build_zero_cst for reference types.
            * typeck2.c (process_init_constructor_record): Instead call
            build_zero_cst here during error recovery instead of
build_zero_init.

            * g++.dg/ubsan/pr95693.C: New test.

    (cherry picked from commit e5750f847158e7f9bdab770fd9c5fff58c5074d3)

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

* [Bug sanitizer/95693] [8/9 Regression] Incorrect error from undefined behavior sanitizer
  2020-06-16  5:12 [Bug c++/95693] New: Incorrect error from undefined behavior sanitizer gcc-90 at tbilles dot hu
                   ` (12 preceding siblings ...)
  2021-04-22 16:49 ` cvs-commit at gcc dot gnu.org
@ 2021-04-22 17:06 ` jakub at gcc dot gnu.org
  2021-04-23 14:14 ` gcc-90 at tbilles dot hu
  14 siblings, 0 replies; 16+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-04-22 17:06 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #12 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed.

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

* [Bug sanitizer/95693] [8/9 Regression] Incorrect error from undefined behavior sanitizer
  2020-06-16  5:12 [Bug c++/95693] New: Incorrect error from undefined behavior sanitizer gcc-90 at tbilles dot hu
                   ` (13 preceding siblings ...)
  2021-04-22 17:06 ` jakub at gcc dot gnu.org
@ 2021-04-23 14:14 ` gcc-90 at tbilles dot hu
  14 siblings, 0 replies; 16+ messages in thread
From: gcc-90 at tbilles dot hu @ 2021-04-23 14:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #13 from Tibor Billes <gcc-90 at tbilles dot hu> ---
Thank you all for fixing it!

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

end of thread, other threads:[~2021-04-23 14:14 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-16  5:12 [Bug c++/95693] New: Incorrect error from undefined behavior sanitizer gcc-90 at tbilles dot hu
2020-06-16  6:43 ` [Bug sanitizer/95693] [8/9/10/11 Regression] " rguenth at gcc dot gnu.org
2020-06-16  6:57 ` marxin at gcc dot gnu.org
2020-06-16  7:24 ` jakub at gcc dot gnu.org
2020-06-16  8:41 ` redi at gcc dot gnu.org
2021-01-14  9:02 ` rguenth at gcc dot gnu.org
2021-01-14 12:58 ` nathan at gcc dot gnu.org
2021-01-21 13:50 ` jakub at gcc dot gnu.org
2021-01-22 18:05 ` cvs-commit at gcc dot gnu.org
2021-01-22 18:06 ` [Bug sanitizer/95693] [8/9/10 " jakub at gcc dot gnu.org
2021-01-29 19:19 ` cvs-commit at gcc dot gnu.org
2021-01-29 19:24 ` [Bug sanitizer/95693] [8/9 " jakub at gcc dot gnu.org
2021-04-20 23:31 ` cvs-commit at gcc dot gnu.org
2021-04-22 16:49 ` cvs-commit at gcc dot gnu.org
2021-04-22 17:06 ` jakub at gcc dot gnu.org
2021-04-23 14:14 ` gcc-90 at tbilles dot hu

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