Even if the function returns a ref, the assignment (as you showed it) would not capture the ref. It would assign the value. I think you probably wanted ret& var=some_class_instance.get_some_member(); I think the problem with inlining, that you think you are seeing, is just what I always call "stirring the pot". When you have a serious bug, the symptoms may be hidden. When you make an irrelevant change the symptoms might appear or disappear creating the illusion that the irrelevant change was relevant. You haven't added or removed the bug, just stirred things to change the appearance of the bug. I don't think there is a real chance of a gcc bug in all this, so this is likely the wrong forum for a serious discussion of the problem. In the right forum, you would need to post more detail of the relevant declarations to get better help. On 07/10/15, achkan wrote: ret & some_class::get_some_member() ... var=some_class_instance.get_some_member();//the address of the variable