------- Additional Comments From dberlin at gcc dot gnu dot org 2004-11-16 22:43 ------- Actually, I think this is a remarkably bad idea, and would like to close this as wontfix.
Pure and const are things that are not easily verifiable by the compiler in a lot of common cases (it may get false negatives), and it's something the user is affirmatively asserting. In short, you shouldn't be saying it's pure or const if it's not pure or const. If the compiler could tell whether you were right or not in all cases, you wouldn't need the attributes in the first place. False negatives appear commonly because left to it's own devices, no external function could be marked pure or const by the compiler (because it has no idea about what they do), and any function that called external functions could get false negatives (because if the compiler couldn't rely on your assertions about const or pure, these functions would also necessarily be not const or pure). If the compiler is allowed to rely on your assertions when trying to verify it for purposes of this warning, then the warning would miss cases where you got it wrong anyway, because it would rely on your wrong assertion :P. So basically, this is not something we can verify in anything but the most trivial cases, we almost always end up relying on what the user tells us. And if the user is marking trivial functions const or pure when they clearly aren't, they deserve what they get :). -- What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |WAITING http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18487