https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100409
--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> --- (In reply to Harald van Dijk from comment #4) > The documentation for the pure attribute refers to "functions that have no > observable effects on the state of the program other than to return a value" > which implies not throwing exceptions, the Wsuggest-attribute=pure text says > that pure functions have to return normally, and the presence of throw > statements suppresses the compiler's suggestion to mark functions as pure. > This function throws, so should the fact that it is marked pure not simply > make the whole thing undefined? It has been consensus that throwing exceptions and const/pure are different concepts that co-exist. See for example the recent discussion at https://gcc.gnu.org/pipermail/gcc-patches/2021-May/569435.html