Built-in function question
Ian Lance Taylor
iant@google.com
Wed Oct 26 16:50:00 GMT 2011
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
More information about the Gcc
mailing list