public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/29185] inconsistent warning: deleting array
       [not found] <bug-29185-4@http.gcc.gnu.org/bugzilla/>
@ 2012-05-23  1:31 ` paolo.carlini at oracle dot com
  2012-05-23 14:20 ` paolo at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 14+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-05-23  1:31 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|gcc-bugs at gcc dot gnu.org |
         AssignedTo|unassigned at gcc dot       |paolo.carlini at oracle dot
                   |gnu.org                     |com
   Target Milestone|---                         |4.8.0
      Known to fail|                            |

--- Comment #9 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-05-23 01:27:17 UTC ---
Mine.


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

* [Bug c++/29185] inconsistent warning: deleting array
       [not found] <bug-29185-4@http.gcc.gnu.org/bugzilla/>
  2012-05-23  1:31 ` [Bug c++/29185] inconsistent warning: deleting array paolo.carlini at oracle dot com
@ 2012-05-23 14:20 ` paolo at gcc dot gnu.org
  2012-05-23 14:20 ` paolo at gcc dot gnu.org
  2012-05-23 14:35 ` paolo.carlini at oracle dot com
  3 siblings, 0 replies; 14+ messages in thread
From: paolo at gcc dot gnu.org @ 2012-05-23 14:20 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

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

--- Comment #11 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-05-23 14:20:37 UTC ---
Done.


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

* [Bug c++/29185] inconsistent warning: deleting array
       [not found] <bug-29185-4@http.gcc.gnu.org/bugzilla/>
  2012-05-23  1:31 ` [Bug c++/29185] inconsistent warning: deleting array paolo.carlini at oracle dot com
  2012-05-23 14:20 ` paolo at gcc dot gnu.org
@ 2012-05-23 14:20 ` paolo at gcc dot gnu.org
  2012-05-23 14:35 ` paolo.carlini at oracle dot com
  3 siblings, 0 replies; 14+ messages in thread
From: paolo at gcc dot gnu.org @ 2012-05-23 14:20 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> 2012-05-23 14:19:37 UTC ---
Author: paolo
Date: Wed May 23 14:19:27 2012
New Revision: 187801

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=187801
Log:
/cp
2012-05-23  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/29185
    * decl2.c (delete_sanity): Extend 'deleting array' warning to
    any array type.

/testsuite
2012-05-23  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/29185
    * g++.dg/warn/delete-array-1.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/warn/delete-array-1.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/decl2.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug c++/29185] inconsistent warning: deleting array
       [not found] <bug-29185-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2012-05-23 14:20 ` paolo at gcc dot gnu.org
@ 2012-05-23 14:35 ` paolo.carlini at oracle dot com
  3 siblings, 0 replies; 14+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-05-23 14:35 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

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

--- Comment #10 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> 2012-05-23 14:19:37 UTC ---
Author: paolo
Date: Wed May 23 14:19:27 2012
New Revision: 187801

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=187801
Log:
/cp
2012-05-23  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/29185
    * decl2.c (delete_sanity): Extend 'deleting array' warning to
    any array type.

/testsuite
2012-05-23  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/29185
    * g++.dg/warn/delete-array-1.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/warn/delete-array-1.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/decl2.c
    trunk/gcc/testsuite/ChangeLog

--- Comment #11 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-05-23 14:20:37 UTC ---
Done.


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

* [Bug c++/29185] inconsistent warning: deleting array
  2006-09-22 16:36 [Bug c++/29185] New: " sebor at roguewave dot com
                   ` (7 preceding siblings ...)
  2006-09-26 21:43 ` sebor at roguewave dot com
@ 2006-09-28 16:16 ` sebor at roguewave dot com
  8 siblings, 0 replies; 14+ messages in thread
From: sebor at roguewave dot com @ 2006-09-28 16:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from sebor at roguewave dot com  2006-09-28 16:16 -------
The EDG guys don't think this is worth spending the committee's time on so I
won't
be proposing any change to the standard. Issuing just a warning rather than an
error is good enough for me.

Also, I opened bug 29273 to remove the error from the dynamic_cast expression
with an array argument since that one is well-formed as well (see comment 2),
according to the same paragraph.


-- 


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


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

* [Bug c++/29185] inconsistent warning: deleting array
  2006-09-22 16:36 [Bug c++/29185] New: " sebor at roguewave dot com
                   ` (6 preceding siblings ...)
  2006-09-26 19:01 ` pinskia at physics dot uc dot edu
@ 2006-09-26 21:43 ` sebor at roguewave dot com
  2006-09-28 16:16 ` sebor at roguewave dot com
  8 siblings, 0 replies; 14+ messages in thread
From: sebor at roguewave dot com @ 2006-09-26 21:43 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from sebor at roguewave dot com  2006-09-26 21:43 -------
You're right, those weren't the best examples, but I still think they
illustrate the point. The code in them is plain ill-formed even though
it never gets executed, because it just doesn't make sense. deleting
an array also doesn't make sense so it might as well be ill-formed.
I'll leave it to the committee to decide if that's a worthwhile change
to the language.


-- 


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


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

* [Bug c++/29185] inconsistent warning: deleting array
  2006-09-22 16:36 [Bug c++/29185] New: " sebor at roguewave dot com
                   ` (5 preceding siblings ...)
  2006-09-26 18:56 ` sebor at roguewave dot com
@ 2006-09-26 19:01 ` pinskia at physics dot uc dot edu
  2006-09-26 21:43 ` sebor at roguewave dot com
  2006-09-28 16:16 ` sebor at roguewave dot com
  8 siblings, 0 replies; 14+ messages in thread
From: pinskia at physics dot uc dot edu @ 2006-09-26 19:01 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from pinskia at physics dot uc dot edu  2006-09-26 19:00 -------
Subject: Re:  inconsistent warning: deleting array

> 
> 
> 
> ------- Comment #5 from sebor at roguewave dot com  2006-09-26 18:56 -------
> You mean something like: if (is_pointer (p)) delete p;
> 
> I suppose that could happen but why should it be any different than other
> non-sensical but lexically valid constructs with undefined behavior that
> require a diagnostic today? E.g.:
> 
>     template <int N>
>     void foo () {
>         if (0 < N) {
>             int array [N];
>             ...
>         }
>     }

That is not undefined behavior, just plain invalid.

> 
> Or:
> 
>     template <class T, class U>
>     U* bar (T *p) {
>         if (is_convertible<T*, U*>)
>             return p;
>         return 0;
>     }

Likewise.  This is a different issue.

> Isn't template metaprogramming the expected solution to this type of a problem?

int a[1];
int *b = a;
delete b;
is also undefined but it is hard to reject without having flow contrl inside
the
front-end.


-- pinski


-- 


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


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

* Re: [Bug c++/29185] inconsistent warning: deleting array
  2006-09-26 18:56 ` sebor at roguewave dot com
@ 2006-09-26 19:00   ` Andrew Pinski
  0 siblings, 0 replies; 14+ messages in thread
From: Andrew Pinski @ 2006-09-26 19:00 UTC (permalink / raw)
  To: gcc-bugzilla; +Cc: gcc-bugs

> 
> 
> 
> ------- Comment #5 from sebor at roguewave dot com  2006-09-26 18:56 -------
> You mean something like: if (is_pointer (p)) delete p;
> 
> I suppose that could happen but why should it be any different than other
> non-sensical but lexically valid constructs with undefined behavior that
> require a diagnostic today? E.g.:
> 
>     template <int N>
>     void foo () {
>         if (0 < N) {
>             int array [N];
>             ...
>         }
>     }

That is not undefined behavior, just plain invalid.

> 
> Or:
> 
>     template <class T, class U>
>     U* bar (T *p) {
>         if (is_convertible<T*, U*>)
>             return p;
>         return 0;
>     }

Likewise.  This is a different issue.

> Isn't template metaprogramming the expected solution to this type of a problem?

int a[1];
int *b = a;
delete b;
is also undefined but it is hard to reject without having flow contrl inside the
front-end.


-- pinski


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

* [Bug c++/29185] inconsistent warning: deleting array
  2006-09-22 16:36 [Bug c++/29185] New: " sebor at roguewave dot com
                   ` (4 preceding siblings ...)
  2006-09-26 17:42 ` pinskia at gcc dot gnu dot org
@ 2006-09-26 18:56 ` sebor at roguewave dot com
  2006-09-26 19:00   ` Andrew Pinski
  2006-09-26 19:01 ` pinskia at physics dot uc dot edu
                   ` (2 subsequent siblings)
  8 siblings, 1 reply; 14+ messages in thread
From: sebor at roguewave dot com @ 2006-09-26 18:56 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from sebor at roguewave dot com  2006-09-26 18:56 -------
You mean something like: if (is_pointer (p)) delete p;

I suppose that could happen but why should it be any different than other
non-sensical but lexically valid constructs with undefined behavior that
require a diagnostic today? E.g.:

    template <int N>
    void foo () {
        if (0 < N) {
            int array [N];
            ...
        }
    }

Or:

    template <class T, class U>
    U* bar (T *p) {
        if (is_convertible<T*, U*>)
            return p;
        return 0;
    }

Isn't template metaprogramming the expected solution to this type of a problem?


-- 


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


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

* [Bug c++/29185] inconsistent warning: deleting array
  2006-09-22 16:36 [Bug c++/29185] New: " sebor at roguewave dot com
                   ` (3 preceding siblings ...)
  2006-09-26 16:31 ` sebor at roguewave dot com
@ 2006-09-26 17:42 ` pinskia at gcc dot gnu dot org
  2006-09-26 18:56 ` sebor at roguewave dot com
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-09-26 17:42 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from pinskia at gcc dot gnu dot org  2006-09-26 17:42 -------
(In reply to comment #3)
> FWIW, I think it should be ill-formed with diagnostic required since the
> behavior of the expression is always undefined.

There are cases where this can show up in templates, someway or another.  And
then undefined behavior at runtime cannot be rejected because someone it does
not need to be run as someone could do:
if (0)
  delete a;


-- 


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


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

* [Bug c++/29185] inconsistent warning: deleting array
  2006-09-22 16:36 [Bug c++/29185] New: " sebor at roguewave dot com
                   ` (2 preceding siblings ...)
  2006-09-22 16:57 ` sebor at roguewave dot com
@ 2006-09-26 16:31 ` sebor at roguewave dot com
  2006-09-26 17:42 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: sebor at roguewave dot com @ 2006-09-26 16:31 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from sebor at roguewave dot com  2006-09-26 16:31 -------
The response I got from EDG is that the expression is well-formed because of
5, p8. They do agree that issuing a warning would be useful and opened an
enhancement request.

FWIW, I think it should be ill-formed with diagnostic required since the
behavior of the expression is always undefined.


-- 


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


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

* [Bug c++/29185] inconsistent warning: deleting array
  2006-09-22 16:36 [Bug c++/29185] New: " sebor at roguewave dot com
  2006-09-22 16:43 ` [Bug c++/29185] " pinskia at gcc dot gnu dot org
  2006-09-22 16:44 ` pinskia at gcc dot gnu dot org
@ 2006-09-22 16:57 ` sebor at roguewave dot com
  2006-09-26 16:31 ` sebor at roguewave dot com
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: sebor at roguewave dot com @ 2006-09-22 16:57 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from sebor at roguewave dot com  2006-09-22 16:57 -------
Yes, but 5.3.5, p1 says "The operand shall have a pointer type, or a class
type having a single conversion function (12.3.2) to a pointer type." and
not "shall be convertible to a pointer type." Note that gcc issues a hard
error for a dynamic_cast expression whose argument is an array, so I would
expect it to treat the delete expression the same since they both have the
same requirement WRT pointers.

Btw., I sent an email to EDG to request that they at least warn and to find
out whether they think it's well-formed. I'll update the incident with their
response.  Also note that both IBM XLC++ and HP aCC issue an error for the
test case.


-- 


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


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

* [Bug c++/29185] inconsistent warning: deleting array
  2006-09-22 16:36 [Bug c++/29185] New: " sebor at roguewave dot com
  2006-09-22 16:43 ` [Bug c++/29185] " pinskia at gcc dot gnu dot org
@ 2006-09-22 16:44 ` pinskia at gcc dot gnu dot org
  2006-09-22 16:57 ` sebor at roguewave dot com
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-09-22 16:44 UTC (permalink / raw)
  To: gcc-bugs



-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|minor                       |enhancement


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


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

* [Bug c++/29185] inconsistent warning: deleting array
  2006-09-22 16:36 [Bug c++/29185] New: " sebor at roguewave dot com
@ 2006-09-22 16:43 ` pinskia at gcc dot gnu dot org
  2006-09-22 16:44 ` pinskia at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-09-22 16:43 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2006-09-22 16:43 -------
> (ill-fomed?)
I think it is valid because of how arrays decay to pointers (EDG also accepts
the code).

Confirmed, we just do the warning for array type decls:
  /* An array can't have been allocated by new, so complain.  */
  if (TREE_CODE (exp) == VAR_DECL
      && TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE)
    warning (0, "deleting array %q#D", exp);


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |minor
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
  GCC build triplet|all                         |
   GCC host triplet|all                         |
 GCC target triplet|all                         |
           Keywords|                            |diagnostic
   Last reconfirmed|0000-00-00 00:00:00         |2006-09-22 16:43:41
               date|                            |


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


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

end of thread, other threads:[~2012-05-23 14:20 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-29185-4@http.gcc.gnu.org/bugzilla/>
2012-05-23  1:31 ` [Bug c++/29185] inconsistent warning: deleting array paolo.carlini at oracle dot com
2012-05-23 14:20 ` paolo at gcc dot gnu.org
2012-05-23 14:20 ` paolo at gcc dot gnu.org
2012-05-23 14:35 ` paolo.carlini at oracle dot com
2006-09-22 16:36 [Bug c++/29185] New: " sebor at roguewave dot com
2006-09-22 16:43 ` [Bug c++/29185] " pinskia at gcc dot gnu dot org
2006-09-22 16:44 ` pinskia at gcc dot gnu dot org
2006-09-22 16:57 ` sebor at roguewave dot com
2006-09-26 16:31 ` sebor at roguewave dot com
2006-09-26 17:42 ` pinskia at gcc dot gnu dot org
2006-09-26 18:56 ` sebor at roguewave dot com
2006-09-26 19:00   ` Andrew Pinski
2006-09-26 19:01 ` pinskia at physics dot uc dot edu
2006-09-26 21:43 ` sebor at roguewave dot com
2006-09-28 16:16 ` sebor at roguewave dot com

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