Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
* isalign option on cxx?
@ 1996-02-23  5:00 Alan Rotnemer
  1996-02-23  5:00 ` Tom Carlson
  0 siblings, 1 reply; 3+ messages in thread
From: Alan Rotnemer @ 1996-02-23  5:00 UTC (permalink / raw)


The native "cc" compiler has a -misalign option which	
(at a price) allows access to data on other than its 
"natural" boundaries.  I did not see a similar 
option on the c++ (cxx) compiler.  Running DUNIX 3.2C.	
Is there such an option?  Thanks.



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: isalign option on cxx?
  1996-02-23  5:00 isalign option on cxx? Alan Rotnemer
@ 1996-02-23  5:00 ` Tom Carlson
  1996-02-28  5:00   ` Alan Rotnemer
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Carlson @ 1996-02-23  5:00 UTC (permalink / raw)



In article <4gjh3v$7cd$1@mhadf.production.compuserve.com>, Alan Rotnemer <73765.1577@CompuServe.COM> writes:
|>The native "cc" compiler has a -misalign option which	
|>(at a price) allows access to data on other than its 
|>"natural" boundaries.  I did not see a similar 
|>option on the c++ (cxx) compiler.  Running DUNIX 3.2C.	
|>Is there such an option?  Thanks.

The current DEC C++ provides no such option.

However, we are currently field testing a new DEC C++ compiler
which does provide this support and more.  The present schedule,
I believe has this new product out sometime in April.

Tom

--

Thomas Carlson,   DEC C/ DEC C++     carlson@decc.enet.dec.com
Digital Equipment Corporation,  ZK2-3/N30           
110 Spitbrook Rd,
Nashua, NH  03062



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: isalign option on cxx?
  1996-02-23  5:00 ` Tom Carlson
@ 1996-02-28  5:00   ` Alan Rotnemer
  0 siblings, 0 replies; 3+ messages in thread
From: Alan Rotnemer @ 1996-02-28  5:00 UTC (permalink / raw)


Tom:

Thank you for your reply to my question regarding the "isalign"
option.

I wonder if you would be familiar with the following problem I
recently ran into while porting code from another UNIX platform.
The code that I listed below yields different results from the
"cc" and "cxx" compilers (no compiler options).  It seems that
the cxx compiler has a problem with a pointer reference to
the unsigned short within a struct when the field is not on 
an even boundary and the structure is packed. "cc" works OK.
Is this a bug in cxx?

Thanks again.

Alan Rotnemer


#include <stdio.h>
#include<stdlib.h> 
#pragma pack 1
	struct aa
	{
		char cc1[7]  ;
		unsigned short us  ;
	};
 
	struct aa xaa;
void main()
{
        struct aa *pxaa, *pxaa1, *pxaa2;
        pxaa = &xaa;
	xaa.us = (unsigned short ) 299;
        printf("size of aa struct is %u\n", sizeof(struct aa));
	printf ("dot non-calloc 299 moved to %u\n",  xaa.us);
	printf ("...but using ptr ref its is %u\n",  pxaa->us);
	printf("...hex is ptr: %x, dot: %x \n", pxaa->us, xaa.us);
	pxaa->us = (unsigned short ) 299;
	printf ("pointer non-calloc 299 moved to %u\n",
		pxaa->us);
	printf ("....but using dot ref it is %u\n", xaa.us);
        pxaa1 = (struct aa *) calloc(1, sizeof(struct aa));
        pxaa1->us = 299;
	printf ("calloc ptr ref 299 moved to %u\n", 
		pxaa1->us);
}
#pragma pack 8
***************************************************************************
on cc compiler I get ...

size of aa struct is 9
dot non-calloc 299 moved to 299
..but using ptr ref its is 299
..hex is ptr: 12b, dot: 12b 
pointer non-calloc 299 moved to 299
...but using dot ref it is 299
calloc ptr ref 299 moved to 299
****************************************************************************

on cxx compiler I get..

size of aa struct is 9
dot non-calloc 299 moved to 299
..but using ptr ref its is 43
..hex is ptr: 2b, dot: 12b 
pointer non-calloc 299 moved to 43
...but using dot ref it is 299
calloc ptr ref 299 moved to 43



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1996-02-28  5:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1996-02-23  5:00 isalign option on cxx? Alan Rotnemer
1996-02-23  5:00 ` Tom Carlson
1996-02-28  5:00   ` Alan Rotnemer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox