public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/31893] Please provide an "inout" attribute for function parameters.
       [not found] <bug-31893-4@http.gcc.gnu.org/bugzilla/>
@ 2012-03-16 23:26 ` manu at gcc dot gnu.org
  2013-08-28  8:25 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: manu at gcc dot gnu.org @ 2012-03-16 23:26 UTC (permalink / raw)
  To: gcc-bugs

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

Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |NEW

--- Comment #6 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2012-03-16 23:22:35 UTC ---
(In reply to comment #5)
> There is no support for this in the middle-end anyway. Not even for Fortran.

And with GCC 4.7.0, there is, and FORTRAN is using it. See PR43665 and 

http://gcc.gnu.org/ml/gcc-patches/2010-04/msg00895.html

but there is no external interface exposing this functionality in C/C++. That
thread includes some suggestions. If you are still interested, you could try to
submit a patch implementing some of the suggestions.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c/31893] Please provide an "inout" attribute for function parameters.
       [not found] <bug-31893-4@http.gcc.gnu.org/bugzilla/>
  2012-03-16 23:26 ` [Bug c/31893] Please provide an "inout" attribute for function parameters manu at gcc dot gnu.org
@ 2013-08-28  8:25 ` rguenth at gcc dot gnu.org
  2015-06-10 10:39 ` bugzilla@poradnik-webmastera.com
  2015-06-10 13:45 ` redi at gcc dot gnu.org
  3 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-08-28  8:25 UTC (permalink / raw)
  To: gcc-bugs

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

Bug 31893 depends on bug 31094, which changed state.

Bug 31094 Summary: Support annotating function parameters as read-only and/or non-escaping
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31094

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |RESOLVED
         Resolution|---                         |FIXED


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c/31893] Please provide an "inout" attribute for function parameters.
       [not found] <bug-31893-4@http.gcc.gnu.org/bugzilla/>
  2012-03-16 23:26 ` [Bug c/31893] Please provide an "inout" attribute for function parameters manu at gcc dot gnu.org
  2013-08-28  8:25 ` rguenth at gcc dot gnu.org
@ 2015-06-10 10:39 ` bugzilla@poradnik-webmastera.com
  2015-06-10 13:45 ` redi at gcc dot gnu.org
  3 siblings, 0 replies; 9+ messages in thread
From: bugzilla@poradnik-webmastera.com @ 2015-06-10 10:39 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=31893

Daniel Fruzynski <bugzilla@poradnik-webmastera.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@poradnik-webmaster
                   |                            |a.com

--- Comment #7 from Daniel Fruzynski <bugzilla@poradnik-webmastera.com> ---
I am looking for something similar - I want to mark function argument as an
output-only. Now when I compile following code with -Wall -O1 (using gcc
4.4.7), I get following waring: 'myVar' may be used uninitialized in this
function. With help of new function or function argument attribute this warning
would go away. This new attribute may also enable additional code optimizations
and warnings. I propose syntax __attribute__((out)).

void __attribute__((const)) func(int* i)
{
    *i = 44;
}

int func2()
{
    int myVal;
    func(&myVal);
    return myVal;
}


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c/31893] Please provide an "inout" attribute for function parameters.
       [not found] <bug-31893-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2015-06-10 10:39 ` bugzilla@poradnik-webmastera.com
@ 2015-06-10 13:45 ` redi at gcc dot gnu.org
  3 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2015-06-10 13:45 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=31893

--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Daniel Fruzynski from comment #7)
> void __attribute__((const)) func(int* i)
> {
>     *i = 44;
> }

You get a warning because you marked this function const, which tells the
compiler it won't modify *i, so you lied to the compiler.

You should not be marking this function const.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c/31893] Please provide an "inout" attribute for function parameters.
  2007-05-10 10:01 [Bug c/31893] New: " madcoder at debian dot org
                   ` (3 preceding siblings ...)
  2008-08-18 16:51 ` manu at gcc dot gnu dot org
@ 2008-08-18 17:15 ` manu at gcc dot gnu dot org
  4 siblings, 0 replies; 9+ messages in thread
From: manu at gcc dot gnu dot org @ 2008-08-18 17:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from manu at gcc dot gnu dot org  2008-08-18 17:14 -------
There is no support for this in the middle-end anyway. Not even for Fortran.


-- 

manu at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  BugsThisDependsOn|                            |31094


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c/31893] Please provide an "inout" attribute for function parameters.
  2007-05-10 10:01 [Bug c/31893] New: " madcoder at debian dot org
                   ` (2 preceding siblings ...)
  2007-05-11  8:33 ` madcoder at debian dot org
@ 2008-08-18 16:51 ` manu at gcc dot gnu dot org
  2008-08-18 17:15 ` manu at gcc dot gnu dot org
  4 siblings, 0 replies; 9+ messages in thread
From: manu at gcc dot gnu dot org @ 2008-08-18 16:51 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from manu at gcc dot gnu dot org  2008-08-18 16:50 -------
This would need to be a GCC extension and those need some high-level approval,
so still unconfirmed, however I am marking as waiting until a decision is
taken.

You should seek opinions/support in the gcc mailing list. It seems no one has
asked for such an extension before.

I think the standard answer will be "GCC is a C compiler, use other language if
you want other features" but who knows...


-- 

manu at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |manu at gcc dot gnu dot org
             Status|UNCONFIRMED                 |WAITING


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c/31893] Please provide an "inout" attribute for function parameters.
  2007-05-10 10:01 [Bug c/31893] New: " madcoder at debian dot org
  2007-05-10 10:13 ` [Bug c/31893] " madcoder at debian dot org
  2007-05-10 22:01 ` pinskia at gcc dot gnu dot org
@ 2007-05-11  8:33 ` madcoder at debian dot org
  2008-08-18 16:51 ` manu at gcc dot gnu dot org
  2008-08-18 17:15 ` manu at gcc dot gnu dot org
  4 siblings, 0 replies; 9+ messages in thread
From: madcoder at debian dot org @ 2007-05-11  8:33 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from madcoder at debian dot org  2007-05-11 09:32 -------
Subject: Re:  Please provide an "inout" attribute for function parameters.

On Thu, May 10, 2007 at 10:00:51PM -0000, pinskia at gcc dot gnu dot org wrote:
> ------- Comment #2 from pinskia at gcc dot gnu dot org  2007-05-10 23:00 -------
> What are you doing, writting Fortran code in C? :) (really I am serious about
> this one too)
>
> > It seems that even if the argument is declared const foo_t * gcc assumes the
> > function will initialize the data, which is rather ... erm... strange.
>
> Why do you think it is strange? you can remove the const part in do_bar
> anyways.

  I know you *can* but it's very bad practice, and when you're a warning
freak like I am, I won't mark a variable "const" if the function will
eventually change it. Anyways, that does not changes my request, that is
to mark the fact that the data must be pre-initialized before use to
make -Wuninitialized even more useful :)


-- 


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c/31893] Please provide an "inout" attribute for function parameters.
  2007-05-10 10:01 [Bug c/31893] New: " madcoder at debian dot org
  2007-05-10 10:13 ` [Bug c/31893] " madcoder at debian dot org
@ 2007-05-10 22:01 ` pinskia at gcc dot gnu dot org
  2007-05-11  8:33 ` madcoder at debian dot org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-05-10 22:01 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2007-05-10 23:00 -------
What are you doing, writting Fortran code in C? :) (really I am serious about
this one too)

> It seems that even if the argument is declared const foo_t * gcc assumes the
> function will initialize the data, which is rather ... erm... strange.

Why do you think it is strange? you can remove the const part in do_bar
anyways.


-- 


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c/31893] Please provide an "inout" attribute for function parameters.
  2007-05-10 10:01 [Bug c/31893] New: " madcoder at debian dot org
@ 2007-05-10 10:13 ` madcoder at debian dot org
  2007-05-10 22:01 ` pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: madcoder at debian dot org @ 2007-05-10 10:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from madcoder at debian dot org  2007-05-10 11:12 -------
It seems that even if the argument is declared const foo_t * gcc assumes the
function will initialize the data, which is rather ... erm... strange. Here is
the testcase:

======================================================
struct foo { int toto; };

void do_bar(const struct foo *);

int main(void) {
    struct foo foo;
    do_bar(&foo);
    return 0;
}
======================================================

gcc -Wall -Wextra -O2 -Wuninitialized -c -o foo.o foo.c

gives no warning while I'd expect to have one as do_bar takes a const foo_t *
hence should not initialize it.


-- 


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-06-10 13:45 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-31893-4@http.gcc.gnu.org/bugzilla/>
2012-03-16 23:26 ` [Bug c/31893] Please provide an "inout" attribute for function parameters manu at gcc dot gnu.org
2013-08-28  8:25 ` rguenth at gcc dot gnu.org
2015-06-10 10:39 ` bugzilla@poradnik-webmastera.com
2015-06-10 13:45 ` redi at gcc dot gnu.org
2007-05-10 10:01 [Bug c/31893] New: " madcoder at debian dot org
2007-05-10 10:13 ` [Bug c/31893] " madcoder at debian dot org
2007-05-10 22:01 ` pinskia at gcc dot gnu dot org
2007-05-11  8:33 ` madcoder at debian dot org
2008-08-18 16:51 ` manu at gcc dot gnu dot org
2008-08-18 17:15 ` manu at gcc dot gnu dot org

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).