This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Built-in function question
- From: Ian Lance Taylor <iant at google dot com>
- To: ZoltÃn KÃcsi <zoltan at bendor dot com dot au>
- Cc: gcc at gcc dot gnu dot org
- Date: Wed, 26 Oct 2011 06:18:11 -0700
- Subject: Re: Built-in function question
- References: <20111026202927.38579ddb@tade.bendor.com.au>
ZoltÃn KÃcsi <zoltan@bendor.com.au> writes:
> However:
>
> int (*bar( void ))( unsigned )
> {
> return __builtin_popcount;
> }
>
> returns the address of the label "__builtin_popcount", which does not exist:
>
> int main( int arcg, char *argv[] )
> {
> (void) argv;
> return (*bar())( argc );
> }
>
> fails to compile because of an undefined reference to __builtin_popcount.
...
> I believe that the above is an issue, but I don't know if it is bug or a
> feature, i.e. a compiler or a documentation issue?
It's a documentation issue, and also a compiler issue in that the
compiler should give an error for this.
__builtin_popcount will compile to the popcnt instruction on x86_64 if
you use -march=corei7-avx.
Ian