public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/42126]  New: gcc optimizes line away/optimizes to an endless loop
@ 2009-11-20 22:27 codemasterhs at yahoo dot de
  2009-11-20 22:28 ` [Bug c/42126] " codemasterhs at yahoo dot de
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: codemasterhs at yahoo dot de @ 2009-11-20 22:27 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 988 bytes --]

The problem with the endless loop is in the function "smpAllocMsg". There gcc
makes out of the while loop ("freeList == 0") an endless loop.

The problem with the line which is optimized away is in the
smpSendMsgBroadcast, its the line "serviceMsg= msg". This problem can be
avoided if I call another function (I tested printf) before the while loop
(msg->refCount > 0).

These 2 problems only occur if I use the "-O2" switch with "-O1" it works.

What I do not understand is, why is gcc doing that, although I´m using the
volatile keyword!?


-- 
           Summary: gcc optimizes line away/optimizes to an endless loop
           Product: gcc
           Version: 4.4.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: codemasterhs at yahoo dot de
  GCC host triplet: cygwin
GCC target triplet: i586-elf


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


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

* [Bug c/42126] gcc optimizes line away/optimizes to an endless loop
  2009-11-20 22:27 [Bug c/42126] New: gcc optimizes line away/optimizes to an endless loop codemasterhs at yahoo dot de
@ 2009-11-20 22:28 ` codemasterhs at yahoo dot de
  2009-11-20 22:46 ` schwab at linux-m68k dot org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: codemasterhs at yahoo dot de @ 2009-11-20 22:28 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from codemasterhs at yahoo dot de  2009-11-20 22:28 -------
Created an attachment (id=19070)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=19070&action=view)
the out from gcc with -v -save-temps


-- 


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


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

* [Bug c/42126] gcc optimizes line away/optimizes to an endless loop
  2009-11-20 22:27 [Bug c/42126] New: gcc optimizes line away/optimizes to an endless loop codemasterhs at yahoo dot de
  2009-11-20 22:28 ` [Bug c/42126] " codemasterhs at yahoo dot de
@ 2009-11-20 22:46 ` schwab at linux-m68k dot org
  2009-11-20 22:51 ` codemasterhs at yahoo dot de
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: schwab at linux-m68k dot org @ 2009-11-20 22:46 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from schwab at linux-m68k dot org  2009-11-20 22:45 -------
Neither freeList nor serviceMsg are volatile.  Thus freeList can never change
and serviceMsg = msg is a dead assignment.


-- 

schwab at linux-m68k dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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


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

* [Bug c/42126] gcc optimizes line away/optimizes to an endless loop
  2009-11-20 22:27 [Bug c/42126] New: gcc optimizes line away/optimizes to an endless loop codemasterhs at yahoo dot de
  2009-11-20 22:28 ` [Bug c/42126] " codemasterhs at yahoo dot de
  2009-11-20 22:46 ` schwab at linux-m68k dot org
@ 2009-11-20 22:51 ` codemasterhs at yahoo dot de
  2009-11-20 23:53 ` rguenth at gcc dot gnu dot org
  2009-11-21  9:02 ` codemasterhs at yahoo dot de
  4 siblings, 0 replies; 6+ messages in thread
From: codemasterhs at yahoo dot de @ 2009-11-20 22:51 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from codemasterhs at yahoo dot de  2009-11-20 22:50 -------
(In reply to comment #2)
> Neither freeList nor serviceMsg are volatile.  Thus freeList can never change
> and serviceMsg = msg is a dead assignment.
> 

But they are, or is my syntax wrong?

static volatile struct smpMsg_t *serviceMsg;
static volatile struct smpMsg_t *freeList;


-- 

codemasterhs at yahoo dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |


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


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

* [Bug c/42126] gcc optimizes line away/optimizes to an endless loop
  2009-11-20 22:27 [Bug c/42126] New: gcc optimizes line away/optimizes to an endless loop codemasterhs at yahoo dot de
                   ` (2 preceding siblings ...)
  2009-11-20 22:51 ` codemasterhs at yahoo dot de
@ 2009-11-20 23:53 ` rguenth at gcc dot gnu dot org
  2009-11-21  9:02 ` codemasterhs at yahoo dot de
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-11-20 23:53 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from rguenth at gcc dot gnu dot org  2009-11-20 23:53 -------
The pointer is not declared volatile.

static struct smpMsg_t * volatile freeList;

would be a volatile pointer.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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


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

* [Bug c/42126] gcc optimizes line away/optimizes to an endless loop
  2009-11-20 22:27 [Bug c/42126] New: gcc optimizes line away/optimizes to an endless loop codemasterhs at yahoo dot de
                   ` (3 preceding siblings ...)
  2009-11-20 23:53 ` rguenth at gcc dot gnu dot org
@ 2009-11-21  9:02 ` codemasterhs at yahoo dot de
  4 siblings, 0 replies; 6+ messages in thread
From: codemasterhs at yahoo dot de @ 2009-11-21  9:02 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 502 bytes --]



------- Comment #5 from codemasterhs at yahoo dot de  2009-11-21 09:02 -------
(In reply to comment #4)
> The pointer is not declared volatile.
> 
> static struct smpMsg_t * volatile freeList;
> 
> would be a volatile pointer.
> 

Ok, this worked. So where has to be the volatile keyword, so that everything
works? I mean I thought "volatile TYPE (like int, char and so on) foo" is
right, isn´t it? Or does this only not work for pointers?


-- 


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


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

end of thread, other threads:[~2009-11-21  9:02 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-20 22:27 [Bug c/42126] New: gcc optimizes line away/optimizes to an endless loop codemasterhs at yahoo dot de
2009-11-20 22:28 ` [Bug c/42126] " codemasterhs at yahoo dot de
2009-11-20 22:46 ` schwab at linux-m68k dot org
2009-11-20 22:51 ` codemasterhs at yahoo dot de
2009-11-20 23:53 ` rguenth at gcc dot gnu dot org
2009-11-21  9:02 ` codemasterhs at yahoo dot de

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