This is the mail archive of the gcc@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: Built-in function question


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


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