public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/24016] New: Missing "operation on xxx may be undefined" on obvious undefined code
@ 2005-09-22 17:15 pinskia at gcc dot gnu dot org
  2005-09-22 17:25 ` [Bug c/24016] " joseph at codesourcery dot com
  0 siblings, 1 reply; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-09-22 17:15 UTC (permalink / raw)
  To: gcc-bugs

Take the following example:
void f(int *a)
{
  *a++ = __extension__ ({ int bb = *a; bb; });
}
---
We don't warn for the operation on a.  This is most likely we don't look into a BLOCK or a statement list, 
I don't know which one.  If I remove the declation of bb, it works, so I am going to assume we don't 
look into BLOCKs.

This was reduced from the following code with glibc and -O1:
#include <ctype.h>
void strtolower(char *data) { while (*data != '\0') *data++ = tolower(*data); }

-- 
           Summary: Missing "operation on xxx may be undefined" on obvious
                    undefined code
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: enhancement
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pinskia at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org


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


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

* [Bug c/24016] Missing "operation on xxx may be undefined" on obvious undefined code
  2005-09-22 17:15 [Bug c/24016] New: Missing "operation on xxx may be undefined" on obvious undefined code pinskia at gcc dot gnu dot org
@ 2005-09-22 17:25 ` joseph at codesourcery dot com
  0 siblings, 0 replies; 2+ messages in thread
From: joseph at codesourcery dot com @ 2005-09-22 17:25 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From joseph at codesourcery dot com  2005-09-22 17:24 -------
Subject: Re:  New: Missing "operation on xxx may be undefined"
 on obvious undefined code

On Thu, 22 Sep 2005, pinskia at gcc dot gnu dot org wrote:

> Take the following example:
> void f(int *a)
> {
>   *a++ = __extension__ ({ int bb = *a; bb; });
> }

I'm not convinced this is undefined: statement expressions act like 
(inline) function calls for the purpose of sequence point rules so the 
execution of the statement expression suspends the execution of the rest 
of the surrounding expression and there are sequence points at the 
beginning and end of the statement expression.

It is, however, at least unspecified order of evaluation and a warning 
here would still make sense.



-- 


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


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

end of thread, other threads:[~2005-09-22 17:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-22 17:15 [Bug c/24016] New: Missing "operation on xxx may be undefined" on obvious undefined code pinskia at gcc dot gnu dot org
2005-09-22 17:25 ` [Bug c/24016] " joseph at codesourcery 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).