This is the mail archive of the gcc-bugs@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]
Other format: [Raw text]

[Bug c++/60517] warning/error for taking address of member of a temporary object


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60517

--- Comment #5 from Marc Glisse <glisse at gcc dot gnu.org> ---
(In reply to Manuel LÃpez-IbÃÃez from comment #4)
> Where is the clobber added?

front-end, I expect (sorry, I'm trying to get something to work on windows and
don't have my usual sources at hand).

> The closer to the FE that we warn, the better
> diagnostic we can generate.

Then do it in the front-end and ignore my message ;-)

> I'm not very concerned about maybe-branches, since 
> I expect most bugs to appear in temporaries created in the middle of
> expressions (such as a.getB().getA().x), where no branching occurs.

An exemple I have in mind is (pseudo):
ref id(ref x){return x;}
ref fun(){return id(temporary);}
where the function call hides that we are returning a reference to a temporary
(id could return a reference to a global object, for all fun knows) and we know
more after inlining (I need id inlined into fun, and either fun inlined into
something that uses its returned ref (so my previous technique works) or I
would need a different (middle-end) warning that detects return &local_var,
which seems even easier except that it would give a lot of duplicates with
front-end warnings).

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