* Re: bug in cpp used by cc?
1998-02-12 5:00 bug in cpp used by cc? Franz Gaehler
@ 1998-02-12 5:00 ` Steve Peltz
1998-02-16 5:00 ` Jeff Sullivan
0 siblings, 1 reply; 3+ messages in thread
From: Steve Peltz @ 1998-02-12 5:00 UTC (permalink / raw)
In article <34E304A2.E18B39D@itap.physik.uni-stuttgart.de>,
Franz Gaehler <gaehler@itap.physik.uni-stuttgart.de> wrote:
> typedef unsigned long int * * Bag;
> #define ADDR_OBJ PTR_BAG
> #define PTR_BAG(bag) (*(Bag**)(bag))
>I suspect that the behaviour of cc should be called a bug. Or is this
>the expected behaviour? Are there any fixes or work arounds known?
Yeah, I'd call it a bug as well. Doesn't happen with the old (OSF) C compiler,
does happen with the DEC C compiler (-migrate on older systems).
A work-around would be:
#define ADDR_OBJ(x) PTR_BAG(x)
Another work-around would be to run your program through cpp directly, rather
than let the C compiler do it. You may want to pass the -no_cpp flag to the
C compiler to not bother trying to expand it again, but since the pre-
processing is built in it probably doesn't save you anything.
Another bug I found is that it doesn't swallow pre-processor directives if
the line before it has a continuation (actually, it was a bug in my code,
but the DEC C compiler didn't catch it; found it using gcc):
#if 0
#define WOOF woof \
#else
#define XYZ xyz
#endif
WOOF
XYZ
SHOULD produce:
WOOF
XYZ
DOES produce:
WOOF
xyz
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug in cpp used by cc?
@ 1998-02-12 5:00 Franz Gaehler
1998-02-12 5:00 ` Steve Peltz
0 siblings, 1 reply; 3+ messages in thread
From: Franz Gaehler @ 1998-02-12 5:00 UTC (permalink / raw)
I'm having a problem with the macro preprocessor used by DEC C (V5.2-033
on Digital UNIX V4.0 (Rev. 564.32)). Consider the file prog.c containing
the following code:
typedef unsigned long int * * Bag;
#define ADDR_OBJ PTR_BAG
#define PTR_BAG(bag) (*(Bag**)(bag))
void CleanBlistCopy ( Bag list )
{
ADDR_OBJ(list)[0] = ADDR_OBJ( ADDR_OBJ(list)[0] )[0];
}
If I do "cc -E prog.c", the body of the function CleanBlistCopy becomes:
(*(Bag**)(list))[0] = (*(Bag**)(ADDR_OBJ(list)[0]))[0];
In other words, one of the macros is not expanded. On the other hand,
if I do "cpp prog.c -", the macro is expanded as it should:
(*(Bag**)(list))[0] = (*(Bag**)( (*(Bag**)(list))[0] ))[0];
I suspect that the behaviour of cc should be called a bug. Or is this
the expected behaviour? Are there any fixes or work arounds known?
Franz G\"ahler
---
Franz G\"ahler
ITAP, University of Stuttgart
gaehler@itap.physik.uni-stuttgart.de
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: bug in cpp used by cc?
1998-02-12 5:00 ` Steve Peltz
@ 1998-02-16 5:00 ` Jeff Sullivan
0 siblings, 0 replies; 3+ messages in thread
From: Jeff Sullivan @ 1998-02-16 5:00 UTC (permalink / raw)
To: gaehler
This does appear to be a problem in the DEC C V5.2 compiler (and
support updates) for Digital UNIX V4.0. It appears to be fixed in
DEC C V5.6 (and later), which is the default compiler for Digital
UNIX V4.0D (and later).
As a workaround, you could use "cpp" or "cc -oldc" to preprocess
this file, as described in the first reply.
-Jeff
--
Jeff Sullivan | Digital Equipment Corp | E-mail: jps@zk3.dec.com
DEC C and C++ | Nashua, NH ZK3-2/2X09 | sullivan@decc.enet.dec.com
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~1998-02-16 5:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1998-02-12 5:00 bug in cpp used by cc? Franz Gaehler
1998-02-12 5:00 ` Steve Peltz
1998-02-16 5:00 ` Jeff Sullivan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox