throw(), pure and const flags on functions

Gabriel Dos Reis dosreis@gmail.com
Thu Apr 16 03:04:00 GMT 2009


On Tue, Apr 14, 2009 at 10:11 AM, Mark Mitchell <mark@codesourcery.com> wrote:
> Paolo Carlini wrote:
>
>>> Only functions both defined and used within single compilation unit are
>>> fine without decorations.  LTO change definition of compilation unit to
>>> "whole program without shared libraries".
>
> Paolo, you asked my opinion on this.  My feeling is that, of course, it
> would be best if the compiler could figure this out.  But, in many cases
> it cannot even in theory (as soon as there's a function call to a
> function it can't see, including a call through a function pointer).
> Calls to C library functions are one special case; if those are not
> decorated with "throw()", for example, then the compiler may not realize
> that they do not throw.  That's not much of problem when using GLIBC,
> since it has the annotations, but other C libraries are not as good
> about that -- and GLIBC probably doesn't have "pure" and "const" in all
> possible places.

 Many of the C functions we call are standard C functions.
The compiler already optimizes those functions based on their
C standard semantics without assuming any GLIBC specific
semantics.  I think the compiler could just rely on those semantics
in this case too.



More information about the Libstdc++ mailing list