Re: expression statements, volatiles, and C vs. C++

2010-03-06 Thread Andrew Haley
On 03/06/2010 04:43 AM, John Regehr wrote:
> The question is, what should C and C++ compilers do with this code?
> 
>   volatile int x;
> 
>   void foo (void) {
> x;
>   }
> 
> This question is not totally stupid: embedded systems use code like this
> when reading a hardware register has a useful side effect (usually
> clearing the register).
> 
> It is reasonably clear that a C compiler should load from x and throw
> away the value.  gcc does this, as do most decent C compilers.
> 
> However, g++ also loads from x and this does not appear to be supported
> by the 1998 C++ standard.  In 6.2, it is explicitly stated that for an
> expression statement, no conversion from lvalue to rvalue occurs.  If
> there's no rvalue, there should not be a load from x.

I'm not sure this follows.  It's stated explicitly that "The
expression is evaluated and its value is discarded."  How can you
evaluate the expression without reading the volatle?

Also, there's the non-normative [Note: volatile is a hint to the
implementation to avoid aggressive optimization involving the object
because the value of the object might be changed by means undetectable
by an implementation. See 1.9 for detailed semantics. In general, the
semantics of volatile are intended to be the same in C++ as they are
in C. ]

Besides, all that changing this would do is break programs.

Andrew.


Phil's regression hunter: How does it work?

2010-03-06 Thread Peter Maier

The gcc developers seem to have nice tool referred to as "Phil's regression 
hunter". Where can I find documentation on it? I'm interested to know how it 
works and its abilities. Is it maybe even available for download?

- Peter

  
_
Hotmail: Trusted email with powerful SPAM protection.
https://signup.live.com/signup.aspx?id=60969


Re: expression statements, volatiles, and C vs. C++

2010-03-06 Thread John Regehr

I'm not sure this follows.  It's stated explicitly that "The
expression is evaluated and its value is discarded."  How can you
evaluate the expression without reading the volatle?


I'm certainly not an expert on this material but I wouldn't think you'd 
normally read a variable in order to evaluate it as an lvalue.  My guess 
is that evaluating the expression means computing the address for 
something like "*(p+1)".



Also, there's the non-normative [Note: volatile is a hint to the
implementation to avoid aggressive optimization involving the object
because the value of the object might be changed by means undetectable
by an implementation. See 1.9 for detailed semantics. In general, the
semantics of volatile are intended to be the same in C++ as they are
in C. ]


Yep.


Besides, all that changing this would do is break programs.


Well they're broken anyway since widely-used C++ compilers are choosing to 
not read the variable under these circumstances.  The obvious solution is 
"don't do that" but there's plenty of code doing this out there, and 
plenty of developers who need re-educating.


John


Re: expression statements, volatiles, and C vs. C++

2010-03-06 Thread Andrew Haley
On 06/03/10 15:54, John Regehr wrote:
>> I'm not sure this follows.  It's stated explicitly that "The
>> expression is evaluated and its value is discarded."  How can you
>> evaluate the expression without reading the volatle?
> 
> I'm certainly not an expert on this material but I wouldn't think you'd
> normally read a variable in order to evaluate it as an lvalue.  My guess
> is that evaluating the expression means computing the address for
> something like "*(p+1)".

Yes, I see your point.

>> Besides, all that changing this would do is break programs.
> 
> Well they're broken anyway since widely-used C++ compilers are choosing
> to not read the variable under these circumstances.  The obvious
> solution is "don't do that" but there's plenty of code doing this out
> there, and plenty of developers who need re-educating.

I guess.  Given that the semantics of volatile are implementation-
defined anyway, I can't see that this is a conformance issue.

Andrew.



Anybody interested in a dead code analysis tool for gcc

2010-03-06 Thread D.J. Barrow
Hi there,
I worked for Pace in Yorkshire in 2006
& developed software to find dead code in large projects &
automatically remove it from files.

The code is rotting as it is unmaintained & is of
no benefit to Pace.

I tried to persuade them to give it to gnu.org
& they wouldn't do it despite the amount
of open source software they use they should
give something back to the community.

If anybody is interested people to ask are.
 L Jane M Connor
Senior Legal Counsel
Pace plc 
Bringing Technology Home
Tel:   +44 (0) 1274 537042
Fax:  +44 (0) 1274 537127
Mob: 07785 733886

david.har...@pace.co.uk 00441274 538182 Software Dev Manager
D.J. Barrow Linux kernel developer
email: dj_bar...@ariasoft.ie
Mobile Ireland: +353-86-1715438
www.travelsmart.ie, everyones favourite carpool website, works beautifully on 
the apple iphone
www.warehog.com, & you thought ebay was good
www.ariasoft.ie, See my GPL contributions


  


Re: FROM FEDERAL BUREAU OF INVESTIGATION SEEKING TO WIRETAP NTERNET

2010-03-06 Thread FBI