Can and should C++ class constructors be declared __attribute__((pure))
if they only can reach data via its parameters? And in which cases should they be qualified as __attribute__((const))
?
C++ class constructors qualified as __attribute__((pure)) or __attribute__((const))
317 views Asked by Nordlöw At
1
GCC warns when you qualify constructors as
pure
orconst
. This is because a constructor does not return anything (returnsvoid
) and it does not make much sense to have apure
orconst
attributes on such functions.See godbolt demo here.
From GCC documentation: