[cfe-users] clang++/g++ difference with __attribute__ ((regparm(0))

Дмитрий Дьяченко dimhen at gmail.com
Sat Apr 13 02:31:06 PDT 2013


Hi!

The following code

extern "C" typedef void __attribute__ ((regparm (0))) Callback ();
void f();
Callback *pf = f;

compiles with g++ and trigger error message from clang++

$ /home/dimhen/build/csa/Release+Asserts/bin/clang++ -fsyntax-only callback.ii
callback.ii:4:11: error: cannot initialize a variable of type
'Callback *' (aka 'void (*)()') with an lvalue of type 'void ()'
Callback *pf = f;
          ^    ~
1 error generated.
$ /home/dimhen/build/csa/Release+Asserts/bin/clang++ -v
clang version 3.3 (trunk 179456)
Target: x86_64-unknown-linux-gnu
Thread model: posix

Gcc documentation say
`-mregparm=NUM'
     Control how many registers are used to pass integer arguments.  By
     default, no registers are used to pass arguments, and at most 3
     registers can be used.  You can control this behavior for a
     specific function by using the function attribute `regparm'.
     *Note Function Attributes::.

     *Warning:* if you use this switch, and NUM is nonzero, then you
     must build all modules with the same value, including any
     libraries.  This includes the system libraries and startup modules.

So, regparm(0) will change nothing.

My questions are: is clang++ compatible with g++ ? Or clang++ do smth
different with regparm(0) ?

Thank You,
Dmitry



More information about the cfe-users mailing list