This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C++ PATCH] Fix -fsanitize={null,alignment} of references (PR c++/79572)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Maxim Kuvyrkov <maxim dot kuvyrkov at gmail dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 24 Nov 2017 15:26:11 +0100
- Subject: Re: [C++ PATCH] Fix -fsanitize={null,alignment} of references (PR c++/79572)
- Authentication-results: sourceware.org; auth=none
- References: <20170323203705.GX11094@tucnak> <CAFrzLAqi1RJ5gBRqX+ejuV9ScWAXbaxQhXJ+pqD6x=hOtv7K8Q@mail.gmail.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Fri, Nov 24, 2017 at 05:16:27PM +0300, Maxim Kuvyrkov wrote:
> Using __builtin_printf causes this test to fail sporadically when
> cross-testing. Stdout and stderr output can get mixed in
> cross-testing, so dejagnu might see
> ==
> g++.dg/ubsan/null-8.C:18:7: runtime error: reference binding to null
> pointer of type iref is NULL
> 'const int'
> ==
> instead of
> ==
> g++.dg/ubsan/null-8.C:18:7: runtime error: reference binding to null
> pointer of type 'const int'
> iref is NULL
> ==
>
> Is it essential for this testcase to use __builtin_printf or simple
> "fprintf (stderr, ...)" would do just fine?
That would mean bringing in stdio.h, which is very much undesirable.
If you want, just revert the patch, verify the testcase FAILs,
and then tweak it to say:
__attribute__((noinline, noclone))
void
bar (const *x, int y)
{
asm volatile ("" : : "g" (x), "g" (y) : "memory");
}
and change __builtin_printf ("iref %d\n", iref);
to bar ("iref %d\n", iref);
and __builtin_printf ("iref is NULL\n");
to bar ("iref is NULL\n", 0);
If the test still FAILs and is fixed after you reapply the patch,
the change is preapproved.
Jakub