Time to revisit ATTRIBUTE_PURE?

Kaveh R. Ghazi ghazi@caip.rutgers.edu
Thu Mar 21 09:27:00 GMT 2002


There was some discussion of ATTRIBUTE_PURE/ATTRIBUTE_CONST
and marking gcc functions here:
http://gcc.gnu.org/ml/gcc-patches/2000-04/msg00749.html

The concern was raised by Mark that a function which was initially
marked correctly might be changed later without the coder realizing
that they suddenly made the function no longer pure and this would
cause hard to find bugs.
http://gcc.gnu.org/ml/gcc-patches/2000-04/msg00751.html

With John Wehle's patch that just went in to mark pure static
functions:
http://gcc.gnu.org/ml/gcc-patches/2002-03/msg01208.html
we can supposedly do the reverse and detect incorrect attribute
markings and complain about them (assuming
alias.c:mark_constant_function is appropriately modified and we don't
have too many false positives.)

If that works, perhaps we can further add a hint flag (e.g.
-Wmissing-pure) to suggest extern functions that one might wish to
mark also (ala -Wmissing-noreturn.)

Jan's earlier patch here:
http://gcc.gnu.org/ml/gcc-patches/1999-08n/msg00601.html
claimed a 150kb code size reduction in gcc, if that's still the case,
its probably worth it to pursue.

Opinions?  I can modify mark_constant_function if there are no
technical obstacles raised.

		--Kaveh
--
Kaveh R. Ghazi			Director of Systems Architecture
ghazi@caip.rutgers.edu		Qwest Global Services



More information about the Gcc-patches mailing list