public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Paul Koning <pkoning@equallogic.com>
To: gdr@integrable-solutions.net
Cc: fjh@cs.mu.OZ.AU, rth@redhat.com, geoffk@geoffk.org,
	jbuck@synopsys.com, espie@quatramaran.ens.fr, gcc@gcc.gnu.org
Subject: Re: GCC warnings for unused global variables
Date: Fri, 02 May 2003 15:27:00 -0000	[thread overview]
Message-ID: <16050.36401.47209.64329@pkoning.dev.equallogic.com> (raw)
In-Reply-To: <m3llxpl6mt.fsf@uniton.integrable-solutions.net>

>>>>> "Gabriel" == Gabriel Dos Reis <gdr@integrable-solutions.net> writes:

 Gabriel> Paul Koning <pkoning@equallogic.com> writes:
 >> I can't tell if you're trying to say something that goes directly
 >> against the intent of volatile or not, so let's talk about an
 >> example:

 Gabriel> I'm trying to say that "volatile" is not a *reliable*
 Gabriel> feature to use to write robust code with reproducible
 Gabriel> behaviour.

I don't understand.

"volatile" exists in order to be able to write device drivers and
multiprocessor applications that are robust and have reproducible
behavior.  That's how it has always been used; that's why it exists.

Now you seem to be saying that such code is just lucky when it works.
Why?

 >> static volatile int foo;
 >> 
 >> void test (void) { foo = 1; foo = 1; }
 >> 
 >> Does your statement mean that you believe the compiler is allowed
 >> to optimize this into: void test (void) { foo = 1; } ?

 Gabriel> If it can determine that does nto change the behaviour of
 Gabriel> whole program, yes, it is permitted to do so.

That doesn't really help.  Do you think that the compiler IS able to
determine this and therefore make that change?

Fergus and others pointed out that the compiler cannot possibly make
that determination because by definition volatile variables are
allowed to have side effects that the compiler is unaware of.  

So if what you mean is "yes, if the compiler could tell, it would be
allowed to, but the compiler can by definition never tell, so it
actually is not allowed to" then we are in agreement.

On the other hand, if you mean "it doesn't currently but at some point
in the future gcc will start doing this because it thinks it can make
that determination" then at that point every OS and SMP application
will break.

     paul

  parent reply	other threads:[~2003-05-02 15:27 UTC|newest]

Thread overview: 141+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-01 11:05 Robert Dewar
2003-05-01 16:35 ` Joe Buck
2003-05-01 18:48   ` Geoff Keating
2003-05-01 18:09     ` Joe Buck
2003-05-02  2:46     ` Richard Henderson
2003-05-02  3:48       ` Geoff Keating
2003-05-02  4:14         ` Richard Henderson
2003-05-02  4:18           ` Kean Johnston
2003-05-02  4:21           ` Gareth Pearce
2003-05-02  4:26             ` Richard Henderson
2003-05-02  5:06           ` Geoff Keating
2003-05-02  9:04           ` Fergus Henderson
2003-05-02 12:54             ` Gabriel Dos Reis
2003-05-02 14:15               ` Fergus Henderson
2003-05-02 14:56                 ` Gabriel Dos Reis
2003-05-02 15:07                   ` Paul Jarc
2003-05-02 15:28                     ` Gabriel Dos Reis
2003-05-02 15:45                       ` Paul Jarc
2003-05-02 16:00                         ` Gabriel Dos Reis
2003-05-02 16:23                           ` Paul Jarc
2003-05-02 16:42                           ` Joe Buck
2003-05-02 16:47                             ` Phil Edwards
2003-05-02 17:08                             ` Joel Sherrill
2003-05-02 19:23                               ` Laurent Guerby
2003-05-02 17:43                             ` DJ Delorie
2003-05-02 19:02                             ` Some fun (Was: GCC warnings for unused global variables) Laurent Guerby
2003-05-05 12:08                             ` GCC warnings for unused global variables Bernd Jendrissek
2003-05-02 20:14                         ` Richard Henderson
2003-05-02 21:22                           ` Geoff Keating
2003-05-03  4:37                             ` Kean Johnston
2003-05-03  8:04                               ` Geoff Keating
2003-05-02 15:48                       ` Kean Johnston
2003-05-02 20:11                         ` Richard Henderson
2003-05-02 20:29                           ` tm_gccmail
2003-05-02 20:31                             ` Richard Henderson
2003-05-02 20:33                             ` tm_gccmail
2003-05-02 16:04                       ` Fergus Henderson
2003-05-02 16:39                         ` Gabriel Dos Reis
2003-05-02 20:16                           ` tm_gccmail
2003-05-02 20:27                             ` Gabriel Dos Reis
2003-05-02 15:08                   ` Paul Koning
2003-05-02 15:18                     ` Gabriel Dos Reis
2003-05-02 15:22                       ` Paul Jarc
2003-05-02 15:27                       ` Paul Koning [this message]
2003-05-02 15:47                         ` Gabriel Dos Reis
2003-05-02 16:35                       ` Joe Buck
2003-05-02 17:11                         ` Gabriel Dos Reis
2003-05-02 17:31                           ` Joe Buck
2003-05-02 20:30                           ` Toon Moene
2003-05-08 22:02                   ` Mike Stump
2003-05-09  8:13                     ` Gabriel Dos Reis
2003-05-09 17:10                       ` Mike Stump
2003-05-03 16:49             ` volatile [was: GCC warnings for unused global variables] Michael Eager
2003-05-03 19:00               ` Fergus Henderson
2003-05-04  7:32                 ` Michael Eager
2003-05-04 11:19                   ` Fergus Henderson
2003-05-04 11:26                     ` Gabriel Dos Reis
2003-05-04 12:20                       ` Fergus Henderson
2003-05-04 14:13                         ` Gabriel Dos Reis
2003-05-04 14:27                           ` Fergus Henderson
2003-05-08 12:30                             ` Gabriel Dos Reis
2003-05-08 15:55                               ` Fergus Henderson
2003-05-08 16:07                                 ` Gabriel Dos Reis
2003-05-08 16:44                                   ` Fergus Henderson
2003-05-06  5:35                     ` Alexandre Oliva
2003-05-06 19:09                       ` Geoff Keating
2003-05-06 23:26                         ` Alexandre Oliva
2003-05-08 11:57                       ` Fergus Henderson
2003-05-08 12:44                         ` Gabriel Dos Reis
2003-05-08 15:30                           ` Fergus Henderson
2003-05-08 15:39                             ` Gabriel Dos Reis
2003-05-08 15:37                           ` Michael Eager
2003-05-08 15:58                             ` Gabriel Dos Reis
2003-05-06  5:37               ` Alexandre Oliva
2003-05-07  3:47                 ` Michael Eager
2003-05-07  4:03                   ` Alexandre Oliva
2003-05-07  9:34                     ` Bernd Jendrissek
2003-05-07 22:58                     ` Mike Stump
2003-05-07 23:15                       ` Richard Henderson
2003-05-07 23:53                         ` Mike Stump
2003-05-08 15:31                         ` Michael Eager
2003-05-07 23:16               ` Mike Stump
2003-05-08 15:54                 ` Michael Eager
2003-05-02 13:23           ` GCC warnings for unused global variables Paul Koning
2003-05-02 12:47   ` Gabriel Dos Reis
  -- strict thread matches above, loose matches on Subject: below --
2003-05-12 11:23 Robert Dewar
2003-05-03  5:59 Robert Dewar
2003-05-03  5:47 Robert Dewar
2003-05-02 16:17 Bruce Korb
2003-05-02 16:43 ` Gabriel Dos Reis
2003-05-02 16:51   ` Bruce Korb
2003-05-02 17:06     ` Phil Edwards
2003-05-08 21:35   ` Mike Stump
2003-05-08 22:08     ` Paul Koning
2003-05-09  8:34     ` Gabriel Dos Reis
2003-05-09 18:04       ` Joe Buck
2003-05-09 18:15         ` Paul Koning
2003-05-02 11:53 Bonzini
2003-05-02 16:35 ` David O'Brien
2003-05-02 18:45   ` Laurent Guerby
2003-05-02 21:21     ` David O'Brien
2003-05-02 21:23     ` David O'Brien
2003-05-02 21:57       ` Gabriel Dos Reis
2003-05-02 22:33         ` Neil Booth
2003-05-03  6:57         ` Bonzini
2003-05-04  8:38           ` Gabriel Dos Reis
2003-05-04 15:56             ` David O'Brien
2003-05-08 12:48               ` Gabriel Dos Reis
2003-05-03  6:48   ` Bonzini
2003-05-05 11:27   ` Bernd Jendrissek
2003-05-06  0:50     ` David O'Brien
2003-04-30  0:51 Alexander Kabaev
2003-04-30 14:51 ` Philipp Thomas
     [not found]   ` <20030430233243.GM697@redhat.com>
     [not found]     ` <20030430194730.68abe5b4.kabaev@mail.ru>
2003-05-01  0:22       ` Richard Henderson
2003-05-01 16:38         ` Joe Buck
2003-05-01 16:50           ` Richard Henderson
2003-05-01 17:04             ` Kean Johnston
2003-05-01 17:21               ` Nathan Sidwell
2003-05-01 17:23             ` Joe Buck
     [not found]               ` <mailpost.1051809860.28678@news-sj1-1>
2003-05-01 17:44                 ` cgd
2003-05-01 20:36                   ` Zack Weinberg
2003-05-01 21:34                     ` Neil Booth
2003-05-01 22:40                       ` Zack Weinberg
2003-05-01 17:38             ` Richard Henderson
2003-05-01 18:04               ` Kean Johnston
2003-05-01 19:57                 ` Joe Buck
2003-05-01 18:16                   ` Kean Johnston
2003-05-01 21:00                 ` Richard Henderson
2003-05-01 20:51                   ` Joe Buck
2003-05-02 15:55                   ` David O'Brien
2003-05-08 19:36                     ` Mike Stump
2003-05-08 19:43                       ` David O'Brien
2003-05-08 21:17                         ` Mike Stump
2003-05-02 16:01         ` David O'Brien
2003-05-02 16:14           ` Daniel Jacobowitz
2003-05-02 16:36             ` David O'Brien
2003-05-01 11:01   ` Marc Espie
2003-05-02 12:44     ` Gabriel Dos Reis
2003-05-02 13:32       ` Kean Johnston
2003-05-02 16:38       ` Marc Espie
2003-05-02 16:58         ` Gabriel Dos Reis

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=16050.36401.47209.64329@pkoning.dev.equallogic.com \
    --to=pkoning@equallogic.com \
    --cc=espie@quatramaran.ens.fr \
    --cc=fjh@cs.mu.OZ.AU \
    --cc=gcc@gcc.gnu.org \
    --cc=gdr@integrable-solutions.net \
    --cc=geoffk@geoffk.org \
    --cc=jbuck@synopsys.com \
    --cc=rth@redhat.com \
    /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).