Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Atomic statements execute more than once inside a thread

Reply
Thread Tools

Atomic statements execute more than once inside a thread

 
 
Walter Roberson
Guest
Posts: n/a
 
      09-12-2007
In article <(E-Mail Removed)>,
Richard Heathfield <(E-Mail Removed)> wrote:
>Walter Roberson said:


>> The evidence from the code given was that
>> it was *not* a conforming C compiler that was in use. C with
>> extensions perhaps.


>The code is an entity in its own right, and says nothing about the
>conformance of the compiler. I can store the complete works of
>Shakespeare in a .c file and hand it to gcc if I like. That doesn't
>mean gcc isn't conforming.


The OP described execution-time behaviour of the code, which
included __stdcall in a function declarator before the function name.
If that was compiled and linked to the point where the poster was
worried about execution time behaviour, then the compiler was
non-conformant (assuming that the given code was indeed complete;
it is -possible- that __stdcall is #define'd to nothingness in some
missing code... but it seems unlikely.)

The code also included // comments, which are post C89. There have
been quite a few posts indicating that Microsoft does not have
a conforming C99 compiler and is not interested in having one.
If those posts were accurate, then the compiler successfully
compiled code that was not C89 compliant. Compilers are allowed to
have extensions, but once one speculates about the possibility that
the OP compiled in some extension mode of unknown extent, then the
meaning of the program given becomes unanalyzable.
--
Okay, buzzwords only. Two syllables, tops. -- Laurie Anderson
 
Reply With Quote
 
 
 
 
Walter Roberson
Guest
Posts: n/a
 
      09-12-2007
In article <(E-Mail Removed)>,
Richard Heathfield <(E-Mail Removed)> wrote:

><cough type="splurfleglaargh">
> Microsoft, a minor C vendor? I'm no MS cheerleader, as you probably
> know, but my keyboard is thanking its guardian angel that I wasn't
> drinking coffee when I read that.
></cough>


Microsoft is known as a C++ vendor, a C.Net vendor, a C# vendor,
but as a C vendor??

The "Visual C++ 2005 Features" sheet,
http://msdn2.microsoft.com/en-us/visualc/aa336448.aspx

mentions C exactly once:

Visual C++ 2005 includes the industry-standard Active Template Library
(ATL), the Microsoft Foundation Class (MFC) libraries, and standard
libraries such as the Standard C++ Library, and the C RunTime Library
(CRT), which has been extended to provide security enhanced
alternatives to functions known to pose security issues.

Every other reference on the page implies that the product is C++
not C.

How much of C99 has Microsoft implemented? Are they known to
be in the midst of a Great Leap Forward to get C99 in place?
Or are they indeed a merely a player in the field of standard C
compilers?
--
Is there any thing whereof it may be said, See, this is new? It hath
been already of old time, which was before us. -- Ecclesiastes
 
Reply With Quote
 
 
 
 
Richard Heathfield
Guest
Posts: n/a
 
      09-13-2007
Walter Roberson said:

> In article <(E-Mail Removed)>,
> Richard Heathfield <(E-Mail Removed)> wrote:
>>Walter Roberson said:

>
>>> The evidence from the code given was that
>>> it was *not* a conforming C compiler that was in use. C with
>>> extensions perhaps.

>
>>The code is an entity in its own right, and says nothing about the
>>conformance of the compiler. I can store the complete works of
>>Shakespeare in a .c file and hand it to gcc if I like. That doesn't
>>mean gcc isn't conforming.

>
> The OP described execution-time behaviour of the code, which
> included __stdcall in a function declarator before the function name.
> If that was compiled and linked to the point where the poster was
> worried about execution time behaviour, then the compiler was
> non-conformant (assuming that the given code was indeed complete;
> it is -possible- that __stdcall is #define'd to nothingness in some
> missing code... but it seems unlikely.)


On the contrary. The code was incorrect (it contained at least one
syntax error), and the only obligation upon the implementation in such
circumstances is that it issues at least one diagnostic message. If the
implementation responds to the incorrect code by producing an
executable program, it is entirely within its rights so to do.

> The code also included // comments, which are post C89.


Indeed. That's the "at least one syntax error" I was talking about.

> There have
> been quite a few posts indicating that Microsoft does not have
> a conforming C99 compiler and is not interested in having one.


Neither does GNU have a conforming C99 compiler. Neither do several
other C implementors. Er... so?

> If those posts were accurate, then the compiler successfully
> compiled code that was not C89 compliant.


Yes, it's allowed to do that, as long as it produces a diagnostic
message for any syntax errors or constraint violations. I haven't
compiled the OP's code, but if I were to do so using my Visual C++
implementation (in C mode, of course), I know for sure that a
diagnostic message would be produced.

> Compilers are allowed to
> have extensions, but once one speculates about the possibility that
> the OP compiled in some extension mode of unknown extent, then the
> meaning of the program given becomes unanalyzable.


Sure. No question about that. But that's the program's problem, not the
implementation's.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
 
Reply With Quote
 
Richard Heathfield
Guest
Posts: n/a
 
      09-13-2007
Walter Roberson said:

> In article <(E-Mail Removed)>,
> Richard Heathfield <(E-Mail Removed)> wrote:
>
>><cough type="splurfleglaargh">
>> Microsoft, a minor C vendor? I'm no MS cheerleader, as you probably
>> know, but my keyboard is thanking its guardian angel that I wasn't
>> drinking coffee when I read that.
>></cough>

>
> Microsoft is known as a C++ vendor, a C.Net vendor, a C# vendor,
> but as a C vendor??


Yeah. I've used Microsoft C on so many client sites that I've lost
count. I would not like to have to defend the position that all these
clients bought their C compilers from Microsoft by accident, never
realising that "Visual C++" could compile C until they took off the
shrinkwrap.

> The "Visual C++ 2005 Features" sheet,
> http://msdn2.microsoft.com/en-us/visualc/aa336448.aspx
>
> mentions C exactly once:
>
> Visual C++ 2005 includes the industry-standard Active Template
> Library (ATL), the Microsoft Foundation Class (MFC) libraries, and
> standard libraries such as the Standard C++ Library, and the C
> RunTime Library (CRT), which has been extended to provide security
> enhanced alternatives to functions known to pose security issues.
>
> Every other reference on the page implies that the product is C++
> not C.


Yes, it's true that Microsoft think of C as low-priority. Nevertheless,
they continue to sell a program that compiles C programs using C rules.

> How much of C99 has Microsoft implemented?


I have no idea. My own opinion is that C99 is a dead duck, and I'm not
about to criticise Microsoft for agreeing with me. Of course, that
doesn't stop me from criticising them for all kinds of other stuff.

> Are they known to
> be in the midst of a Great Leap Forward to get C99 in place?
> Or are they indeed a merely a player in the field of standard C
> compilers?


Merely a player? No, they're a player.

Whenever I need to compile C code under Windows, I always turn to my
trusty Visual Studio. It's the best Windows-based C compiler I have.
For C++, I wouldn't touch it with a bargepole unless I had absolutely
no other choice. From my perspective, Microsoft ships a badly-named but
otherwise excellent C compiler, and the fact that they bundle C++ with
it is of no consequence to me.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
 
Reply With Quote
 
Jack Klein
Guest
Posts: n/a
 
      09-13-2007
On Wed, 12 Sep 2007 20:56:29 +0000 (UTC), http://www.velocityreviews.com/forums/(E-Mail Removed)-cnrc.gc.ca
(Walter Roberson) wrote in comp.lang.c:

> In article <(E-Mail Removed)>,
> Richard Heathfield <(E-Mail Removed)> wrote:
> >Walter Roberson said:

>
> >> Visual C++ doesn't immediately sound like a C compiler. Are you
> >> sure you have the right newsgroup? This is the C language newsgroup.

>
> >There's pedantry, and then there's pedantry. For the benefit of anyone
> >who doesn't already know that "Visual C++" includes a C compiler, I
> >have some earth-shattering news for you. "Visual C++" includes a C
> >compiler.

>
> This is comp.lang.c . I'm not supposed to have to keep track of
> all of the compilers from minor C vendors, whose conformance varies
> from week to week. The evidence from the code given was that
> it was *not* a conforming C compiler that was in use. C with extensions
> perhaps.


Just curious, do you know of any C compiler from any vendor that
functions in its most strictly conforming mode by default, that is
with no invocation options? I have never seen one that I recall.

This reminds me of the legal tussle between Microsoft and Sun a decade
and change ago. One of Sun's complaints about Microsoft violating its
Java IP was that Microsoft's compiler accepted Microsoft's extensions,
many of them Windows specific, by default.

But so did Microsoft's C and C++ compilers, and so did (and still do)
Borland's C and C++ compilers. And so did (and so) every version of
gcc I have ever used.

So the question stands, do you know of any C compiler from any source
that uses its most strictly conforming mode by default, and must
actually be invoked with options to allow extensions?

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.club.cc.cmu.edu/~ajo/docs/FAQ-acllc.html
 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      09-13-2007
Jack Klein <(E-Mail Removed)> writes:
[...]
> So the question stands, do you know of any C compiler from any source
> that uses its most strictly conforming mode by default, and must
> actually be invoked with options to allow extensions?


I could construct such a compiler by writing a thin wrapper around,
say, gcc that invokes it with the required options. gcc plus my
wrapper would then constitute a "compiler".

But no, I don't know of any C compiler that works that way "out of the
box".

--
Keith Thompson (The_Other_Keith) http://www.velocityreviews.com/forums/(E-Mail Removed) <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
 
Reply With Quote
 
CBFalconer
Guest
Posts: n/a
 
      09-13-2007
Jack Klein wrote:
>

.... snip ...
>
> So the question stands, do you know of any C compiler from any
> source that uses its most strictly conforming mode by default,
> and must actually be invoked with options to allow extensions?


I don't. But, point of order: Twenty years ago my PascalP was, by
default, restricted to ISO standard Pascal. Extensions were
available. I maintain this is right and proper.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>


--
Posted via a free Usenet account from http://www.teranews.com

 
Reply With Quote
 
jaysome
Guest
Posts: n/a
 
      09-13-2007
On Wed, 12 Sep 2007 23:53:52 +0200, Tor Rustad
<(E-Mail Removed)> wrote:

>jaysome wrote:
>
>
>> // foo.c
>> int main(void)
>> {
>> // return success status
>> return 0;
>> }
>>
>> When compiled with VC++ 6.0 SP5, I get:
>>
>> foo.c(1) : warning C4001: nonstandard extension 'single line comment'
>> was used
>> foo.c(4) : warning C4001: nonstandard extension 'single line comment'
>> was used
>>
>> When compiled with gcc:
>>
>> gcc foo.c -o foo
>>
>> I get:
>>
>> // no warnings
>>
>> By your definition, Microsoft VC++ 6.0 has compliant behavior and gcc
>> does not, assuming of course that "blowing up" equates to issuing a
>> diagnostic.

>
>Well, in ANSI mode at least my VC++ 6.0 installation do translate:
>
>C:\temp>more test.c
>// foo.c
>int main(void)
>{
> // return success status
> return 0;
>}
>
>C:\temp>cl /Za test.c
>Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8168 for 80x86
>Copyright (C) Microsoft Corp 1984-1998. All rights reserved.
>
>test.c
>Microsoft (R) Incremental Linker Version 6.00.8168
>Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
>
>/out:test.exe
>test.obj
>
>while GNU cc don't need high warning level to reject:
>
>$ cat test.c
>// foo.c
>int main(void)
>{
> // return success status
> return 0;
>}
>$ gcc -ansi test.c


gcc *does* require some "high warning level" option to reject the
code. You added the "-ansi" option to do so. Just like I checked the
box labeled "Disable language extensions" in Visual C++ to do so.

If you're going to use Microsoft Visual C++ to compile C code that you
submit to this newsgroup, consider checking the box labeled "Disable
language extensions" in the project settings. And if you're going to
use gcc to compile C code that you submit to this newsgroup, consider
using these options (at a minimum):

gcc -ansi -pedantic -W -Wall

Any warnings you get from either of these compilers should be
addressed before submitting your code. And if there is a warning that
you don't understand, then IMHO you have a right to ask "why" in this
newsgroup; the explanation for such warnings may well further your
knowledge of Standard C, and benefit others as well.

Regards
--
jay
 
Reply With Quote
 
Tor Rustad
Guest
Posts: n/a
 
      09-13-2007
jaysome wrote:

[...]

> gcc *does* require some "high warning level" option to reject the
> code. You added the "-ansi" option to do so. Just like I checked the
> box labeled "Disable language extensions" in Visual C++ to do so.


No so, in ANSI mode, gcc *rejected* your code at the *default* warning
level.

Furthermore, I showed that Microsoft VC++ 6.0 *translated* your code
without a *warning* when using the /Za switch (at the *default* warning
level):

What point did you make by comparing VC++ in ANSI mode, with gcc in GNU
mode?


> If you're going to use Microsoft Visual C++ to compile C code that you
> submit to this newsgroup, consider checking the box labeled "Disable
> language extensions" in the project settings.


Apparently, you have never used this compiler without the GUI:

cl /help
[...]
/Za disable extensions (implies /Op)



> And if you're going to
> use gcc to compile C code that you submit to this newsgroup, consider
> using these options (at a minimum):
>
> gcc -ansi -pedantic -W -Wall


I prefer stronger checks than this, and usually write lint clean code.

--
Tor <torust [at] online [dot] no>
 
Reply With Quote
 
Tor Rustad
Guest
Posts: n/a
 
      09-13-2007
Walter Roberson wrote:

> In article <(E-Mail Removed)>,
> Richard Heathfield <(E-Mail Removed)> wrote:
>
>> <cough type="splurfleglaargh">
>> Microsoft, a minor C vendor? I'm no MS cheerleader, as you probably
>> know, but my keyboard is thanking its guardian angel that I wasn't
>> drinking coffee when I read that.
>> </cough>

>
> Microsoft is known as a C++ vendor, a C.Net vendor, a C# vendor,
> but as a C vendor??


Sure is.

I didn't like the Microsoft .NET IDE much, so I rapidly swapped back to
using the VC++ 6.0 IDE, but many of my co-workers use the .NET IDE
during their embedded C work.

Before testing the code on target, we simulate it under Windows.

Likewise, when writing C code for mainframes, I always try to test as
much as possible under Windows, before swapping to an editor without
syntax coloring, flat file-system and command-line debugger.


> How much of C99 has Microsoft implemented? Are they known to
> be in the midst of a Great Leap Forward to get C99 in place?


Could very well be. From watching the feedback the VC++ development team
received on their blog, when asking for future wishes, clearly support
for C++0X was requested a lot... and Dinkumware TR1 comes with a C99
library:

http://www.dinkumware.com/tr1.aspx

--
Tor <torust [at] online [dot] no>
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[ANN] atomic 0.0.1 - An atomic reference for Ruby Charles Oliver Nutter Ruby 5 06-08-2010 01:04 PM
single thread decrement a semaphore object more than once? birdsong Python 1 02-25-2009 07:52 AM
Regex to match say char 't' exactly once in a string and no more than once Gancy Perl Misc 4 02-03-2005 02:19 PM
How to execute a aspx page more than once simultanously? =?Utf-8?B?U2l2YXJhbWFuLlM=?= ASP .Net 5 10-15-2004 01:19 AM
execute the statements inside if statement without testing the if expression? Matt Java 3 03-01-2004 08:57 PM



Advertisments