This is the mail archive of the gcc-patches@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]

Re: [C++ PATCH]: __FUNCTION__ handling


Mark Mitchell wrote:
> Does this make us emit __FUNCTION__ just because the user says
> something like:
> 
>   const char *c = __FUNCTION__
> 
> ?  That should still not require that the actual __FUNCTION__ itself
> be emitted; that should only happen if __FUNCTIO__ is addressed.
why?
	void foo ()
	{
		static const char wibble[] = "wibble";
		const char *wptr = wibble;
		const char *fptr = __FUNCTION__;

		assert (fptr == __FUNCTION__);
		assert (wptr == wibble);
	}
`wibble' and `__FUNCTION__' should behave the same here. Both asserts
should be ok.

modulo the asserts, this produces,

        .type    __FUNCTION__.0,@object
        .size    __FUNCTION__.0,4
__FUNCTION__.0:
        .string "foo"
        .type    wibble.1,@object
        .size    wibble.1,7
wibble.1:
        .string "wibble"
.text
        .align 16
.globl foo__Fv
        .type    foo__Fv,@function
foo__Fv:
.LFB1:
        pushl   %ebp
.LCFI0:
        movl    %esp, %ebp
.LCFI1:
        subl    $8, %esp
.LCFI2:
        movl    $wibble.1, -4(%ebp)
        movl    $__FUNCTION__.0, -8(%ebp)
        movl    %ebp, %esp
        popl    %ebp
        ret

Let me know if you agree, or why you disagree. Thanks for the other nitpicking!

nathan

-- 
Dr Nathan Sidwell   ::   http://www.codesourcery.com   ::   CodeSourcery LLC
         'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org

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