Download raw body.
gcc15: drop -fno-delete-null-pointer-checks local change
On Mon, 17 Nov 2025 14:14:03 +0100, Claudio Jeker <cjeker@diehard.n-r-g.com> wrote: > > In gcc -fdelete-null-pointer-checks is a nightmare. > > It is a stupid optimisation which has some bad security track record since > it tends to remove 'if (p == NULL) error out' checks. Now on OpenBSD you can > not map the page at address 0 so it is less of a concern since in that > case the code should crash before the check (at least that is the theory). > > The problem with skipping this optimisation is that a lot of c++ code > breaks because of static asserts against nullptr. > Many of those expressions are actually not using proper const expressions > and so gcc errors out. With -fdelete-null-pointer-checks these checks > get optimised away (because the compiler decided that somewhen before the > static assert the pointer was already dereferenced and so impossible to be > NULL). > > I got tired to figure out how to pass -fdelete-null-pointer-checks to all > those c++ monsters. The common linux distros all ship with a gcc that has > -fdelete-null-pointer-checks set by default and so we just inflict a lot > of pain on us for being a special snowflake. > OK kirill@ > -- > :wq Claudio > > Index: Makefile > =================================================================== > RCS file: /cvs/ports/lang/gcc/15/Makefile,v > diff -u -p -r1.13 Makefile > --- Makefile 13 Nov 2025 23:30:14 -0000 1.13 > +++ Makefile 17 Nov 2025 12:57:04 -0000 > @@ -18,7 +18,7 @@ V = 15.2.0 > FULL_VERSION = $V > FULL_PKGVERSION = $V > > -REVISION = 3 > +REVISION = 4 > > ADASTRAP-amd64 = adastrap-amd64-11.2.0-5.tar.xz > ADASTRAP-arm = adastrap-arm-4.9.4-0.tar.xz > Index: patches/patch-gcc_common_opt > =================================================================== > RCS file: /cvs/ports/lang/gcc/15/patches/patch-gcc_common_opt,v > diff -u -p -r1.1.1.1 patch-gcc_common_opt > --- patches/patch-gcc_common_opt 18 Aug 2025 19:49:22 -0000 1.1.1.1 > +++ patches/patch-gcc_common_opt 12 Nov 2025 12:57:16 -0000 > @@ -41,15 +41,6 @@ Index: gcc/common.opt > Aggressively optimize loops using language constraints. > > falign-functions > -@@ -1359,7 +1367,7 @@ Common Var(flag_delete_dead_exceptions) Init(0) Optimi > - Delete dead instructions that may throw exceptions. > - > - fdelete-null-pointer-checks > --Common Var(flag_delete_null_pointer_checks) Init(-1) Optimization > -+Common Var(flag_delete_null_pointer_checks) Init(0) Optimization > - Delete useless null pointer checks. > - > - fdevirtualize-at-ltrans > @@ -1943,7 +1951,7 @@ Enum(hardcfr_check_noreturn_calls) String(always) Valu > ; On SVR4 targets, it also controls whether or not to emit a > ; string identifying the compiler. > -- wbr, Kirill
gcc15: drop -fno-delete-null-pointer-checks local change