Re: Function Pointers and Inlining
From: Victor Bazarov (v.Abazarov_at_comAcast.net)
Date: 03/22/05
- Next message: Mark: "Re: How to delete and remove all items in a container<T*>"
- Previous message: Malte Starostik: "Re: How to delete and remove all items in a container<T*>"
- In reply to: James Aguilar: "Re: Function Pointers and Inlining"
- Next in thread: Rolf Magnus: "Re: Function Pointers and Inlining"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 22 Mar 2005 13:46:20 -0500
James Aguilar wrote:
> "Howard" <alicebt@hotmail.com> wrote in message
> news:YzY%d.162941$Th1.160178@bgtnsc04-news.ops.worldnet.att.net...
>
>>Never? I don't think that's correct. If I recall, the implementation is free
>>to inline those calls which it is able to inline. But it must also provide a
>>non-inline version which can be called normally. It's not an all-or-nothing
>>thing, but is handled on a case-by-case basis. At least, that's my
>>understanding.
>
>
> I've been wrong before, but I think I read something about how if you take the
> address of a particular function, that function won't be inlined elsewhere. A
> test shows . . .
>
> --- CODE ---
[...]
> --- CODE ---
>
> I think that if it worked as you say, LINK 1 would be addl $5, %eax or something
> like that. On the other hand, when I get the assembly compiling with -O2, crazy
> stuff happens and I can't read it.
You're arguing different points here. Howard says what the Standard says.
You are demonstrating what you've observed with the compilers you have.
Both are correct but they don't contradict each other.
The Standard does not mandate either behaviour. It should be reasonably
apparent that if somebody takes the address of a function, the body has to
exist somewhere otherwise what would the address point to? However, the
act of putting a copy of the function body with all necessary adjustments
into the code instead of a call to that function (known as "inlining") is
totally up to the compiler. It doesn't have to do it even if you use the
'inline' keyword.
Between two extremes: inlining all [static] calls to that function and
also providing a body elsewhere if the address is taken *and* not inlining
the function at all, is where the behaviour of a compliant compiler lies.
You should see by now that there is nothing to argue about.
V
- Next message: Mark: "Re: How to delete and remove all items in a container<T*>"
- Previous message: Malte Starostik: "Re: How to delete and remove all items in a container<T*>"
- In reply to: James Aguilar: "Re: Function Pointers and Inlining"
- Next in thread: Rolf Magnus: "Re: Function Pointers and Inlining"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|