Skip to content

Comment on How to trick C/C++ compilers into generating terrible code?parent

Comments

A subtle point that bit me, const functions should not read from pointer arguments, such as const char pointers. The pointed to data is external (to the const function) memory.

Also, gcc does not seem to warn about reading eternal memory. It seems like this would be an easy error for the compiler to detect.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.