public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <rguenther@suse.de>
To: Martin Sebor <msebor@gmail.com>
Cc: Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org>,
	    gcc Patches <gcc-patches@gcc.gnu.org>,
	Jan Hubicka <hubicka@ucw.cz>
Subject: Re: [RFC] propagate malloc attribute in ipa-pure-const pass
Date: Thu, 18 May 2017 07:07:00 -0000	[thread overview]
Message-ID: <alpine.LSU.2.20.1705180906070.20726@zhemvz.fhfr.qr> (raw)
In-Reply-To: <89e261a6-1ebd-0e8a-fdf3-4fce98a40ca8@gmail.com>

On Wed, 17 May 2017, Martin Sebor wrote:

> > The patch passes bootstrap+test on x86_64 and found a few functions in
> > the source tree (attached func_names.txt) that could be annotated with
> > malloc (I gave a brief look at some of the functions and didn't appear
> > to be false positives but I will recheck thoroughly)
> 
> virtual char* libcp1::compiler::find(std::__cxx11::string&) const
> 
> The virtual on the list of your candidates gave me pause.  Consider
> this completely contrived example:
> 
>   struct B {
>     virtual void* f (unsigned n) {
>       return new char [n];
>     }
>   };
> 
>   void* foo (B &b, unsigned n)
>   {
>     return b.f (n);
>   }
> 
> Based on these definitions alone both functions are candidates
> for attribute malloc.
> 
> But suppose foo is called with an object of a type derived from
> B that overrides f() to do something wacky (but strictly not
> invalid) like:
> 
>   struct D: B {
>     char buf[32];
>     virtual void* f (unsigned n) {
>       if (n < 32)
>       return n <= 32 ? buf : B::f (n);
>     }
> 
> Breaking foo's attribute malloc constraint.
> 
> In other words, I think virtual functions need to be excluded
> from the list (unless they're defined in a class marked final,
> or unless we know they're not overridden to break the constraint
> like above).

But we are annotating the actual decl, not the type in the class
struct.

Richard.

  reply	other threads:[~2017-05-18  7:06 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-15 10:56 Prathamesh Kulkarni
2017-05-16  1:14 ` Jeff Law
2017-05-16 11:48 ` Richard Biener
2017-05-17 21:22 ` Martin Sebor
2017-05-18  7:07   ` Richard Biener [this message]
2017-05-19 13:18     ` Jan Hubicka
2017-05-19 13:34 ` Jan Hubicka
2017-05-23 13:48   ` Prathamesh Kulkarni
2017-07-31 18:23     ` Prathamesh Kulkarni
2017-08-08  4:21       ` Prathamesh Kulkarni
2017-08-17 12:55         ` Prathamesh Kulkarni
2017-09-01  2:39           ` Prathamesh Kulkarni
2017-09-15 12:19             ` Prathamesh Kulkarni
2017-09-25 18:13               ` Prathamesh Kulkarni
2017-09-26  0:24                 ` Jan Hubicka
2017-09-27  1:11                   ` Prathamesh Kulkarni
2017-09-29 19:28                     ` Jan Hubicka
2017-10-06  2:16                       ` Prathamesh Kulkarni
2017-10-06 13:04                         ` Jan Hubicka
2017-10-07  1:46                           ` Prathamesh Kulkarni
2017-10-07 19:35                             ` Jan Hubicka
2017-10-07 22:17                               ` Prathamesh Kulkarni
2017-10-13 23:34                                 ` Prathamesh Kulkarni
2017-10-23  9:37                                   ` Prathamesh Kulkarni
2017-10-24 10:57                                   ` Jan Hubicka
2017-10-25 11:18                                     ` Prathamesh Kulkarni
2017-10-25 15:26                                       ` Jan Hubicka
2017-10-27 10:52                                         ` Prathamesh Kulkarni
2017-10-27 12:20                                           ` Jan Hubicka
2017-10-27 12:44                                           ` Jan Hubicka
2017-10-27 13:00                                             ` Richard Biener

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LSU.2.20.1705180906070.20726@zhemvz.fhfr.qr \
    --to=rguenther@suse.de \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hubicka@ucw.cz \
    --cc=msebor@gmail.com \
    --cc=prathamesh.kulkarni@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).