Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Diagnostics (continued)

Reply
Thread Tools

Diagnostics (continued)

 
 
jacob navia
Guest
Posts: n/a
 
      07-15-2008
Consider this nice C program:

short long n;
signed unsigned b;
const long const long a;
unsigned double w;
signed float k;
short double q;
unsigned long double z;

I was astonished that my dear lcc-win very bad diagnostic messages
wrote for those errors.

After correcting that, I passed this code through MSVC and it
wrote a correct diagnostic for all of those errors... excepting
the last.

unsigned long double is legal?

I have serious doubts.

Besides, MSVC emitted just a warning for repeated qualifiers like
"const long const long"... Isn't that an error?

gcc wrote correct diagnostics for all of them, and all were errors,
not warnings.

PellesC missed "const long const long" completely, but the errors
were as I had it: just "Invalid type specification" instead of a
more specific error.

--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
 
Reply With Quote
 
 
 
 
Keith Thompson
Guest
Posts: n/a
 
      07-15-2008
jacob navia <> writes:
> Consider this nice C program:
>
> short long n;
> signed unsigned b;
> const long const long a;
> unsigned double w;
> signed float k;
> short double q;
> unsigned long double z;
>
> I was astonished that my dear lcc-win very bad diagnostic messages
> wrote for those errors.
>
> After correcting that, I passed this code through MSVC and it
> wrote a correct diagnostic for all of those errors... excepting
> the last.
>
> unsigned long double is legal?
>
> I have serious doubts.


No, ``unsigned long double'' is a constraint violation, as you can
verify by re-reading C99 6.7.2, Type specifiers.

> Besides, MSVC emitted just a warning for repeated qualifiers like
> "const long const long"... Isn't that an error?


No, type *specifiers* may not be repeated (other than "long long" and
variations), but type *qualifiers* such as "const" may be repeated, so
"const long const long" is equivalent to "const long long". (It's
ugly, though, so a warning seems appropriate, though it's not
required.)

C99 6.7.3p4:

If the same qualifier appears more than once in the same
_specifier-qualifier-list_, either directly or via one or more
typedefs, the behavior is the same as if it appeared only once.

The idea, I think, is that if you have a typedef for "const int", you
can still apply "const" to the typedef:

typedef const int c_int;
const c_int x = 42;

(IMHO "const" belongs on the object declaration, not buried in a
typedef, but the language allows it.)

In any case, as you know, the standard doesn't distinguish between
errors and warnings. A warning that doesn't cause translation to fail
can still be a valid "diagnostic message" as required by the standard.

> gcc wrote correct diagnostics for all of them, and all were errors,
> not warnings.


Ok, but many of gcc's required diagnostic are warnings.

> PellesC missed "const long const long" completely,


Probably because it's valid.

> but the errors
> were as I had it: just "Invalid type specification" instead of a
> more specific error.


I don't feel strongly that a more specific error message is necessary,
but that's up to you.

--
Keith Thompson (The_Other_Keith) kst- <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
 
Reply With Quote
 
 
 
 
lawrence.jones@siemens.com
Guest
Posts: n/a
 
      07-16-2008
Keith Thompson <kst-> wrote:
>
> (IMHO "const" belongs on the object declaration, not buried in a
> typedef, but the language allows it.)


And, as I recall, one of the key arguments for allowing redundant
qualifiers in C99 was that sig_atomic_t is allowed to be a volatile
qualified type and without allowing redundant qualifiers there was no
portable way to declare an object of that type that was *guaranteed* to
be volatile.
--
Larry Jones

Fortunately, that was our plan from the start. -- Calvin
 
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
Network Diagnostics pings old ISP =?Utf-8?B?Q2hyaXN0aW5l?= Wireless Networking 0 02-14-2005 06:21 PM
Longhorn Wireless Diagnostics: What's important to you? Eddy Malik [MSFT] Wireless Networking 9 11-03-2004 05:53 PM
Windows Diagnostics Utility Myrt Webb MCSE 2 10-11-2004 02:43 PM
poor man's diagnostics JR Cisco 1 08-07-2004 03:49 AM
<system.diagnostics> error on side-by-side installation... S.K. Dutta ASP .Net 2 07-30-2003 06:55 AM



Advertisments