Thread View: comp.sys.ibm.pc.programmer
9 messages
9 total messages
Started by Mark Gleaves
Wed, 11 Jul 1990 14:31
(fairly minor) bug in Microsoft C V6
Author: Mark Gleaves
Date: Wed, 11 Jul 1990 14:31
Date: Wed, 11 Jul 1990 14:31
28 lines
1710 bytes
1710 bytes
Here's a fun little bug that I just discovered in Microsoft C V6.0.
When I run the following program:
#include <stdio.h>
void main() {
printf("Question marks: '??'");
}
I get the following output:
Question marks: '^
It's not quite what I expected. And it breaks a whole series of
programs I have that use quoted question marks within strings :(
P.S., Does anybody else out there resent being patronized, belittled, and
disbelieved when they try to report a bug to Microsoft Technical Support?
*******************************************************************************
Mark Gleaves Phone: (319)335-9780
Center for Health Effects of Fax: (319)335-9200
Environmental Contamination Internet: cmdglv@vaxa.weeg.uiowa.edu
SHRI, S-112 Westlawn Bitnet: cmdglvva@uiamvs.bitnet
University of Iowa
Iowa City, IA 52246 "Hurrah, boys, we've got them!"
USA - George A. Custer, June 25, 1876.
*******************************************************************************
Re: (fairly minor) non-bug in Microsoft C6.0
Author: Kenneth J. Buck
Date: Wed, 11 Jul 1990 17:53
Date: Wed, 11 Jul 1990 17:53
15 lines
1201 bytes
1201 bytes
In article <1829@ns-mx.uiowa.edu> cmdglv@vaxa.weeg.uiowa.edu writes:
> Here's a fun little bug that I just discovered in Microsoft C V6.0.
> printf("Question marks: '??'");
> I get the following output:
Question marks: '^
Aaahh! but not a bug, I'm afraid...
Note on page 424 of TFM (MSC Advanced Programming Techniques manual),
in the section B.1.7 titled Trigraphs, it is mentioned that the character
sequence ??' translates into the circumflex character. This is included
in the ANSI standard for Trigraph sequences. Sorry, but you'll have to
change your program.
Note: one way to do this is to use the string concatenation feature, as in:
printf ("Question marks: '?" "?'");
Re: (fairly minor) bug in Microsoft C V6
Author: Brynn Rogers
Date: Wed, 11 Jul 1990 18:59
Date: Wed, 11 Jul 1990 18:59
24 lines
1582 bytes
1582 bytes
In article <1829@ns-mx.uiowa.edu> cmdglv@vaxa.weeg.uiowa.edu writes:
> Here's a fun little bug that I just discovered in Microsoft C V6.0.
> printf("Question marks: '??'");
>I get the following output:
> Question marks: '^
> It's not quite what I expected. And it breaks a whole series of
>programs I have that use quoted question marks within strings :(
This is not a bug. ANSI C defines a thing called trigraphs for machines or
terminals that don't have some of the less common characters.
Trigraphs are three character macro like devices that allow you to make
funny characters. Ex. ??= is # ??( is [ ??! is | and ??' is ^ .
There are others.
6.0 is trys to be ANSI in every way it can. Another difference between
5.1 and 6.0 that has given me compiler errors is the fact that the type
of a shift expression now is the same type as the left side of the expression:
(short_v << long_v) is of type short, in 5.1 it would have been a long.
You can still put your ??' in a printf, just type \?\?' or ?\?' .
Brynn
Re: (fairly minor) bug in Microsoft C V6
Author: Lee F Kolakowski
Date: Wed, 11 Jul 1990 20:09
Date: Wed, 11 Jul 1990 20:09
27 lines
1571 bytes
1571 bytes
On 11 Jul 90 14:31:09 GMT,
cmdglv@vaxa.weeg.uiowa.edu (Mark Gleaves) said:
> printf("Question marks: '??'");
> I get the following output:
> Question marks: '^
Way to Microsoft. I thought trigraphs were bad, now we have digraphs too.
--
Frank Kolakowski
======================================================================
|lfk@athena.mit.edu || Lee F. Kolakowski |
|lfk@eastman2.mit.edu || M.I.T. |
|kolakowski@wccf.mit.edu || Dept of Chemistry |
|lfk@mbio.med.upenn.edu || Room 18-506 |
|lfk@hx.lcs.mit.edu || 77 Massachusetts Ave.|
|AT&T: 1-617-253-1866 || Cambridge, MA 02139 |
|--------------------------------------------------------------------|
| #include <woes.h> |
| One-Liner Here! |
======================================================================
Re: (fairly minor) non-bug in Microsoft C V6
Author: Mark Gleaves
Date: Wed, 11 Jul 1990 20:32
Date: Wed, 11 Jul 1990 20:32
26 lines
1703 bytes
1703 bytes
In article <1829@ns-mx.uiowa.edu>, I wrote...
>
> Here's a fun little bug that I just discovered in Microsoft C V6.0.
>When I run the following:
>
> printf("Question marks: '??'");
>
>I get the following output:
>
> Question marks: '^
>
> It's not quite what I expected.
Thanks to all of you who pointed out that ??' is a valid trigraph under the
ANSI C standard. I just wish I would have known that before I wrote all
those programs using MSC 5.1. Live and learn...
*******************************************************************************
Mark Gleaves Phone: (319)335-9780
Center for Health Effects of Fax: (319)335-9200
Environmental Contamination Internet: cmdglv@vaxa.weeg.uiowa.edu
SHRI, S-112 Westlawn Bitnet: cmdglvva@uiamvs.bitnet
University of Iowa
Iowa City, IA 52246 "Hurrah, boys, we've got them!"
USA - George A. Custer, June 25, 1876.
*******************************************************************************
Re: (fairly minor) bug in Microsoft C V6
Author: Neil Weisenfeld
Date: Wed, 11 Jul 1990 22:57
Date: Wed, 11 Jul 1990 22:57
38 lines
2153 bytes
2153 bytes
In article <1829@ns-mx.uiowa.edu> cmdglv@vaxa.weeg.uiowa.edu writes:
>
> Here's a fun little bug that I just discovered in Microsoft C V6.0.
>When I run the following program:
>
> #include <stdio.h>
> void main() {
> printf("Question marks: '??'");
> }
>
>I get the following output:
>
> Question marks: '^
>
> It's not quite what I expected. And it breaks a whole series of
>programs I have that use quoted question marks within strings :(
>
>P.S., Does anybody else out there resent being patronized, belittled, and
>disbelieved when they try to report a bug to Microsoft Technical Support?
>
MS Tech support probably receives much more than its share of "bug" reports.
What you have stumbled upon is not a bug, it is a feature. Since not
all terminals (outside of the UNIX/C/DEC,SUN,AT&T world) can do all of
the characters required by C, the ANSI standard provides a method for
specifying certain characters by sequences known as trigraphs. All
trigraphs begin with a ??. The trigraph for ^ is (yes, you guessed it)
??'. See A12.1 of K&R 2nd Ed.
Neil
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Neil I. Weisenfeld | InterNet: weisen@eniac.seas.upenn.edu
Dept. of Computer and Info. Sciences | USPS: I dunno, I'm moving...
University of Pennsylvania | PENNmail: Don't even try it...
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Re: (fairly minor) non-bug in Microsoft C6.0
Author: Russ Poffenberger
Date: Thu, 12 Jul 1990 15:53
Date: Thu, 12 Jul 1990 15:53
28 lines
1805 bytes
1805 bytes
In article <1990Jul11.175340.12779@granite.cr.bull.com> buck@granite.cr.bull.com (Kenneth J. Buck) writes:
>In article <1829@ns-mx.uiowa.edu> cmdglv@vaxa.weeg.uiowa.edu writes:
>> Here's a fun little bug that I just discovered in Microsoft C V6.0.
>> printf("Question marks: '??'");
>> I get the following output:
> Question marks: '^
>
>Aaahh! but not a bug, I'm afraid...
>Note on page 424 of TFM (MSC Advanced Programming Techniques manual),
>in the section B.1.7 titled Trigraphs, it is mentioned that the character
>sequence ??' translates into the circumflex character. This is included
>in the ANSI standard for Trigraph sequences. Sorry, but you'll have to
>change your program.
>
>Note: one way to do this is to use the string concatenation feature, as in:
> printf ("Question marks: '?" "?'");
The more approved way in 'C' is to use the '\' escape character to force the
character you want. ie
printf ("Question marks: '\?\?'");
Russ Poffenberger DOMAIN: poffen@sj.ate.slb.com
Schlumberger Technologies UUCP: {uunet,decwrl,amdahl}!sjsca4!poffen
1601 Technology Drive CIS: 72401,276
San Jose, Ca. 95110 (408)437-5254
Re: (fairly minor) bug in Microsoft C V6
Author: Stephen Clamage
Date: Thu, 12 Jul 1990 22:29
Date: Thu, 12 Jul 1990 22:29
40 lines
2140 bytes
2140 bytes
cmdglv@vaxa.weeg.uiowa.edu (Mark Gleaves) writes:
> Here's a fun little bug that I just discovered in Microsoft C V6.0.
>When I run the following program:
> #include <stdio.h>
> void main() {
> printf("Question marks: '??'");
> }
>I get the following output:
> Question marks: '^
It's not a Microsoft bug! ANSI C defines 9 sequences of "trigraphs"
(sequences of 3 characters) which are translated into single characters
as the very first stage of program interpretation. These nine
trigraphs provide support for characters required by the C language
but not available in all character sets.
All trigraph sequences begin with two question marks. If in a program,
two question marks are not followed by one of the nine specified
charcters, the two question marks are left unchanged.
By luck, you picked one of the trigraphs in your example. The sequence
??' is converted to ^. Since the whole thing is enclosed in double
quotes, the resulting unmatched single quote is not an error (just wrong).
To produce precisely the output you wish, just escape the second single
quote:
printf("Question marks: '??\'");
It is documented in the ANSI C standard Rationale as a
"quiet change" that some programs employing two question marks in
character or string constants may now produce different results.
So in general, you must check existing programs for two question marks
followed by one of the following:
= ( / ) ' < ! > -
and make an appropriate adjustment. (You can always get precisely the
same result, you just might need to change the source form slightly.)
--
Steve Clamage, TauMetric Corp, steve@taumet.com
Re: (fairly minor) bug in Microsoft C V6
Author: Steve Resnick
Date: Fri, 13 Jul 1990 20:02
Date: Fri, 13 Jul 1990 20:02
26 lines
1689 bytes
1689 bytes
In article <1829@ns-mx.uiowa.edu> cmdglv@vaxa.weeg.uiowa.edu writes: >P.S., Does anybody else out there resent being patronized, belittled, and >disbelieved when they try to report a bug to Microsoft Technical Support? > Yes and no. Almost every time I have talked to Microsoft, I ended up with some idiot on the other side of the phone. As an example I presented some code to them which as a TSR under DOS worked great until QuickBASIC was running. I sent them .ASM source and said: This needs to be assembled and linked as a .COM file. The response was: The resulting .EXE crashes. I told them to run it through EXE2BIN and they said what's that? With that sort of mentality, I can only laugh - It's tough to be belittled by a moron. The one time I talked to somebody with intelligence, I got very straight forward answers (He was quickly moved to another department!) Cheers! Steve . -- -------------------------------------------------------------------------------- Steve Resnick -<stever@octopus.COM apple!octopus!stever sun!vsi1!octopus!stever> 408/241-1533 Process Scientific, Inc. "0x2B|~0x2B THAT is the question!"
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads