diff options
author | Karl Williamson <khw@cpan.org> | 2016-12-12 14:43:19 -0700 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2016-12-14 10:45:02 -0700 |
commit | eafb5713f1d84947573aef6b00c8e4cbdf9a872a (patch) | |
tree | 31234224851e8d9f6264859ae69b4511cf53a022 | |
parent | eeec122d5138f12aeef24360a3bd51f978a8f5ba (diff) | |
download | perl-eafb5713f1d84947573aef6b00c8e4cbdf9a872a.tar.gz |
embed.fnc: Add comments about pure attribute flag
This notes some cautions about using it.
-rw-r--r-- | embed.fnc | 16 |
1 files changed, 14 insertions, 2 deletions
@@ -128,8 +128,20 @@ : : P Pure function: : -: A pure function has no effects except the return value, and the return -: value depends only on params and/or globals. Also implies "R": +: A pure function has no effects except the return value, and the return +: value depends only on params and/or globals. This is a hint to the +: compiler that it can optimize calls to this function out of common +: subexpressions. Consequently if this flag is wrongly specified, it can +: lead to subtle bugs that vary by platform, compiler, compiler version, +: and optimization level. Also, a future commit could easily change a +: currently-pure function without even noticing this flag. So it should +: be used sparingly, only for functions that are unlikely to ever become +: not pure by future commits. It should not be used for static +: functions, as the compiler already has the information needed to make +: the 'pure' determination and doesn't need any hint; so it doesn't add +: value in those cases, and could be dangerous if it causes the compiler +: to skip doing its own checks. It should not be used on functions that +: touch SVs, as those can trigger unexpected magic. Also implies "R": : : proto.h: add __attribute__pure__ : |