binutils-gdb/gdb/testsuite/gdb.base/gcore-relro-pie.c
Gary Benson 2a122642b4 Use volatile pointers when attempting to trigger SIGSEGVs
Clang fails to compile a number of files with the following warning:
indirection of non-volatile null pointer will be deleted, not trap
[-Wnull-dereference].  This commit qualifies the relevant pointers
with 'volatile'.

gdb/testsuite/ChangeLog:

	* gdb.base/bigcore.c (main): Use a volatile pointer when
	attempting to trigger a SIGSEGV.
	* gdb.base/gcore-relro-pie.c (break_here): Likewise.
	* gdb.base/gcore-tls-pie.c (break_here): Likewise.
	* gdb.base/savedregs.c (thrower): Likewise.
	* gdb.mi/mi-syn-frame.c (bar): Likewise.
2020-07-13 14:47:44 +01:00

42 lines
898 B
C

/* Copyright 2013-2020 Free Software Foundation, Inc.
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
void
break_here (void)
{
*(volatile int *) 0 = 0;
}
void
foo (void)
{
break_here ();
}
void
bar (void)
{
foo ();
}
int
main (void)
{
bar ();
return 0;
}