[PATCH] D122841: [analyzer] Consider all addrspaces in null dereference check

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 5 21:39:26 PDT 2022

NoQ added a comment.

I looked up the history. I believe this refers to https://clang.llvm.org/docs/LanguageExtensions.html#memory-references-to-specified-segments:

> Annotating a pointer with address space #256 causes it to be code generated relative to the X86 GS segment register, address space #257 causes it to be relative to the X86 FS segment, and address space #258 causes it to be relative to the X86 SS segment. Note that this is a very very low-level feature that should only be used if you know what you’re doing (for example in an OS kernel).

So basically `((void *__attribute__((address_space(256))) *)0)` is a valid pointer that can be safely dereferenced.

I'm not aware of other situations of this kind. Probably this address space range can be hardcoded, and/or a run-time checker option can be provided to enable/disable this behavior.

  rG LLVM Github Monorepo



More information about the cfe-commits mailing list