From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,f44020e1e23d2af6 X-Google-Attributes: gidfee84,public X-Google-ArrivalTime: 1994-02-16 08:54:56 PST Path: gmd.de!newsserver.jvnc.net!news.edu.tw!news!nctuccca.edu.tw!howland.reston.ans.net!cs.utexas.edu!sdd.hp.com!think.com!paperboy.osf.org!paperboy.osf.org!dsb From: dsb@osf.org (David Boyce) Newsgroups: comp.unix.osf.osf1 Subject: Re: sprintf problem under OSF/1 Date: 16 Feb 1994 16:54:56 GMT Organization: Open Software Foundation Message-ID: References: <2js8kl$mhc@names.maricopa.edu> NNTP-Posting-Host: ets7.osf.org In-reply-to: zagar@names.maricopa.edu's message of 15 Feb 1994 21:49:25 -0700 >> I'm sorry if I'm asking a common problem, but we just got our first >> Alpha and it is driving me crazy. I have an existing application that >> I am trying to port. I have compiled it with the -taso option, and it >> compiles and links without error. However, when I run it, every time >> it encounters simple sprintf errors, it dies with a segmentation >> fault. Does this sound familiar to anyone? Also, is there any >> place that I can find information on what is required to port applications >> to OSF/1? >> Thanks for any information. First: as a point of nomenclature, the problem is not with sprintf under OSF/1, as the subject says. It's with sprintf on an Alpha, i.e. it's a 64-bit porting problem. You'd have the same problem porting your application to an Alpha running VMS or NT, and you wouldn't have it porting to another platform running OSF/1. As for the sprintf problem: the -taso option will only work around the most common coding-portability mistake, which is assuming a pointer will fit in an integer and vice versa. If your code assumes that a long is the same size as an int, -taso can do nothing about that. In particular, when using *printf the following two (incorrect) constructs will work correctly on a platform where sizeof(int)==sizeof(long): printf("%d", ); printf("%ld", ); The print routines examine the format string to determine the sizes to expect for subsequent arguments. On most machines ints and longs are both 32 bits and the above, though sloppy, still works. But on an Alpha the first printf will be looking for a 32-bit (int-sized) quantity and get 64, whereas the second will look for 64 and get 32. I'd guess that your problems come from this. Take a look at the lint(1) man page on an Alpha and look up the -Q option. Pay particular attention to the 'f' suboption. Running lint -Q *.[ch] or similar on your application should show where format string mismatches occur. -- David Boyce dsb@osf.org 617-621-8963