How to detect if building with address sanitizer when building with gcc 4.8?
From the GCC 4.8.0 manual: __SANITIZE_ADDRESS__ This macro is defined, with value 1, when -fsanitize=address is in use.
From the GCC 4.8.0 manual: __SANITIZE_ADDRESS__ This macro is defined, with value 1, when -fsanitize=address is in use.
This is a GCC extension to the standard: You can use the -pedantic option to cause GCC to issue a warning, or -std=c++98 to make in an error, when you use one of these extensions (in case portability is a concern).
The so-called usual arithmetic conversions apply to many binary operators, but not all of them. For example they do not apply to the bit shift operators, &&, ||, comma operator, and assignment operators. This is the rule for the bit shift operators: 6.5.7 … 3 Semantics … The integer promotions are performed on each of … Read more
How much effort are you willing to go to? There’s an obnoxiously obscure way to do it but it requires you to set up a dummy directory to hold surrogates for the system headers. OTOH, it doesn’t require any changes in any of your source code. The same technique works equally well for C code. … Read more
I’d recommend using: -Wall -Wextra -std=c89 -pedantic -Wmissing-prototypes -Wstrict-prototypes \ -Wold-style-definition You should compile with -O as well as -g as some warnings are only available when the optimizer is used (actually, I usually use -O3 for spotting the problems). You might prefer -std=gnu89 as that disables fewer extensions in the libraries. OTOH, if you’re … Read more
The fact that GCC issues a warning usually has nothing to do with whether the construct is legal C, but whether the GCC developers consider it either a likely indication that you meant something other than what you write, or just bad style. Here are some examples: if (x = 0) — you almost surely … Read more
From the (Mac OS X, but others are similar) man page: strip removes or modifies the symbol table attached to the output of the assembler and link editor. This is useful to save space after a program has been debugged and to limit dynamically bound symbols. Note the bit about “after a program has been … Read more
Compiler is free to put such variable into bss as well as into data. For example, GCC has a special option controlling such behavior: -fno-zero-initialized-in-bss If the target supports a BSS section, GCC by default puts variables that are initialized to zero into BSS. This can save space in the resulting code. This option turns … Read more
Am I doing something wrong or is this a bug in gcc? The problem is in 47942806932686753431 part, not in __uint128_t p. According to gcc docs there’s no way to declare 128 bit constant: There is no support in GCC for expressing an integer constant of type __int128 for targets with long long integer less … Read more
I didnt find it in GCC Command-Line Options. That’s because you’re looking at “a modified version of the Command-Line Options section of the GCC Manual.” This is the official list of all possible GCC command-line options, which leads to this section: “3.7 Options to Control Diagnostic Messages Formatting”. This is what the section has to … Read more