delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/04/20/13:56:45

From: pavenis AT lanet DOT lv
To: Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>, djgpp AT delorie DOT com
Date: Thu, 20 Apr 2000 19:38:17 +0200
MIME-Version: 1.0
Subject: Re: 'volatile' undeclared from here
Message-ID: <38FF5CA9.32726.49951@localhost>
In-reply-to: <8dn0q3$dvv$1@nets3.rz.RWTH-Aachen.DE>
X-mailer: Pegasus Mail for Win32 (v3.12c)
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

I tested precompiled source under Linux with 
	egcs-20000418 CVS version 
	gcc-2.95
	egcs-1.1.2

Result: this problem doesn't appear with current gcc CVS version but 
	it appears with both gcc-2.95 and egcs-1.1.2

So: if it is bug then perhaps it's fixed in current development version of 
gcc
	
Andris


On 20 Apr 2000, at 13:30, Hans-Bernhard Broeker wrote:

> Alexandre Devaure <Alexandre DOT Devaure AT leroy-autom DOT com> wrote:
> [...]
> > here is the output of gcc -E :
> 
> OK, thanks. I've confronted Linux/ix86 gcc-2.95.2 with that source file, and
> indeed, it throws the error message you reported:
> 
> [oahu] /tmp $ gcc -c -O2 cppasm.ii      
> tst.cpp: In method `int TValueFifo<bidon,2>::PutSecure(const bidon &)':
> tst.cpp:63:   instantiated from here
> tst.cpp:48: `volatile' undeclared (first use this function)
> tst.cpp:48: (Each undeclared identifier is reported only once
> tst.cpp:48: for each function it appears in.)
> tst.cpp:48: warning:  qualifier ignored on asm
> 
> So I looked into the documentation of gcc-2.95.2, a bit, and I think I
> found a possible reason for that problem: the effect of 'volatile' in
> an inline asm statement only is for *extended* inline asm. Yours is an
> 'old style' one, as it does not specify any input/output/clobber
> lists. For such assembly blocks the gcc-2.95.2 docs say:
> 
> --- quote ---
>    An `asm' instruction without any operands or clobbers (and "old
> style" `asm') will not be deleted or moved significantly, regardless,
> unless it is unreachable, the same wasy as if you had written a
> `volatile' keyword.
> --- end quote ---
> 
> In other words: you don't need the volatile keyword, here, and that's
> why it is being 'ignored', as the 'qualifier ignored' warning message
> from gcc correctly points out.
> 
> So the question remains: why that "`volatile' undeclared" error
> message, in addition to it? And why only if it's compiled as C++?  I'm
> not altogether certain this constitutes a bug in gcc, but it may be
> interpreted as one. OTOH, nowhere in the manual do I find a statement
> that inline is supposed to work in C++ programs *at all*. Strictly
> interpreting the docs, extended inline asm is a C language extension,
> but not necessarily valid in C++.
> 
> In C++, 'asm' seems to be defined as an ANSI/ISO standardized reserved
> word of the language. This may also imply a certain set of semantics
> which disallow use of 'volatile' in non-extended asm blocks.
> 
> Summing it all up: you can work around the problem by simply
> *removing* the volatile keyword, I think. Its desired effect is
> granted anyway, no matter if it's written out or not, in your case.
> 
> [...]
> >         int PutSecure(const bidon& Value)
> >         {
> >                 __asm__ __volatile__("pushf");
> 
> -- 
> Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
> Even if all the snow were burnt, ashes would remain.


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019