RFC: Stricter semantics for renaming pragmas

Gabriel Dos Reis gdr@integrable-solutions.net
Thu May 20 12:57:00 GMT 2004


llewelly@xmission.com writes:

| Gabriel Dos Reis <gdr@integrable-solutions.net> writes:
| 
| > Ian Lance Taylor <ian@wasabisystems.com> writes:
| > 
| > [...]
| > 
| > | > 5) In C++:
| > | > 
| > | > 5a) Applying __asm__("name") to a declaration silently makes it extern "C".
| > | 
| > | Sounds right--that doesn't change the calling convention in any way,
| > | right?  It just changes the name.
| > 
| > I don't really like this part.  Changing a "mangled name" should be
| > separated from declaring something extern "C", and even more so, that
| > declaration should not happen implicitly.  "extern "C" in C++ is not
| > just about changing a mangled name, it may affect types too.
| 
| Are you refering to this:

Yes.  Thanks for examplifying!  

| typedef void(*function)();
| 
| extern "C" void bar(){}
| 
| int main()
|   {
|     function f= &bar; //error.
|   }
| 
| which I think is an error, but g++ (3.4, and 3.5 20040502) do not emit
|     a diagnostic even with pedantic. 7.5/1 says:
| 
|     # [...] Two function types witth different language linkages are
|     # distinct types even if they are otherwise identical.
| 
| and como says:
| 
| /*
| "ComeauTest.c", line 7: error: a value of type "void (*)() C" cannot
| be used to
|           initialize an entity of type "function"
|       function f= &bar; //error.
|                   ^
| */

-- Gaby



More information about the Gcc mailing list