Skip to content

Compiler warning of undefined behaviour: pointer arithmetics on null pointers #28

@ghoffart

Description

@ghoffart

When building ptunnel-ng on macOS 12.3.1/x86_64, there are warnings output:

./autogen.sh
[…]
[…]
test -z "" || rm -f
rm -f *.o
make[1]: Nothing to be done for `clean-am'.
-> make -j4 all
Making all in src
/Applications/Xcode.app/Contents/Developer/usr/bin/make  all-am
  CC       ptunnel_ng-options.o
  CC       ptunnel_ng-challenge.o
  CC       ptunnel_ng-md5.o
  CC       ptunnel_ng-utils.o
md5.c:164:18: warning: performing pointer subtraction with a null pointer has undefined behavior [-Wnull-pointer-subtraction]
            if (!((data - (const md5_byte_t *)0) & 3)) {
                        ^ ~~~~~~~~~~~~~~~~~~~~~
  CC       ptunnel_ng-pkt.o
  CC       ptunnel_ng-pdesc.o
1 warning generated.
  CC       ptunnel_ng-ptunnel.o
  CCLD     ptunnel-ng
make[1]: Nothing to be done for `all-am'.

Compiler:

configure:3992: checking for C compiler version
configure:4001: gcc --version >&5
Apple clang version 13.1.6 (clang-1316.0.21.2.3)
Target: x86_64-apple-darwin21.4.0
Thread model: posix

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions