This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Speed-up get_identifier("main") (take 2)


Roger Sayle <roger@eyesopen.com> writes:

> On Thu, 7 Aug 2003, Zack Weinberg wrote:
>> Jakub Jelinek <jakub@redhat.com> writes:
>> > Why do you need any configure checks?
>> > Simple
>> > #if GCC_VERSION >= 3000
>> > # define get_identifier(str) \
>> >   (__builtin_constant_p (str)					\
>> >    ? get_identifier_with_length ((str), (unsigned) strlen (str))	\
>> >    : get_identifier (str))
>> > #endif
>> >
>> > should do the job and you don't have to worry about side-effects.
>>
>> In fact I believe this construct should be safe all the way back to
>> gcc 2.7, but I don't have convenient access to anything earlier than
>> 2.95.
>
>
> Ok.  Using __builtin_constant_p is much simpler than I'd thought.
>
> Zack, would you like me to bootstrap and regression test this variant?

Yes please.

> My only hesitation is that GCC should really follow the GNU/autoconf
> convention of testing for features rather than checking environments
> or version numbers.  i.e. Intel and I suspect other compilers may
> support GCC's __builtin_constant_p extension.  Testing GCC_VERSION
> sets a bad precedent, and invites these other compilers to masquarade
> as GCC.  Perhaps a configure test would still be more appropriate?

No.  As Andrew pointed out downthread, a configure test will not work,
because it will get the wrong answer in stages 2 and 3 of a bootstrap.  
If you check, you will see that we already use this idiom for finding
out whether we can use other GCC extensions.

(And I don't think there is anything wrong with Intel's compiler
defining __GNUC__ and __GNUC_MINOR__ as an assertion of compatibility
with that version of GCC.  If it isn't 100% compatible, Intel has some
bugs to fix, and that's their problem.  But this is off-topic.)

zw


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]