[Bug middle-end/14505] __builtin_constant_p(__func__) is not true

msebor at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Apr 5 00:24:00 GMT 2016


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=14505

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |NEW

--- Comment #5 from Martin Sebor <msebor at gcc dot gnu.org> ---
Thank you for the feedback.

Having __builtin_constant_p(__func__) return 1 in C++ constexpr contexts makes
sense since it's accepted there (starting with r234530) and treated as a
constant expression.  That it doesn't in 6.0 is likely an oversight.  However,
as evident from a recent discussion on core@lists.isocpp.org, whether or not
__func__ was or is intended be allowed in constexpr functions to begin with is
a subject of ongoing discussion.

On the other hand, it wouldn't be right to do the same thing outside constexpr
constexts or in GCC (i.e., in C mode, as in the example in comment #0) unless
__func__ (or similar objects) really were treated as a compile-time constant.

Of course, if the GCC definition for __builtin_constant_p() were to change, the
value it returned for a given expression would be subject to this new
definition.  If that's the direction you would like to go I suggest to start by
coming up with and proposing the new definition to see what implementation
changes it might require and whether there is consensus to adopt it.

(I've reset the status from Assigned back to New since you didn't assign the
bug to anyone when reopening it.)


More information about the Gcc-bugs mailing list