🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.sgi.apps
Article #77

CC problem: passing/receiving values to functions

#77
From: Eric Buddington
Date: Wed, 01 Nov 1995 21:48
66 lines
2984 bytes
System: IRIX 5.3 on Indy, using SGI's CC and dbx

I compiled a program written in ANSI C using CC -g -cckr -fullwarn.
Most function calls work properly, but two have given me 
nexplainable errors:
---------------------------------------------------------------------
First: A function call that dosn't pass arguments correctly.
Quoted lines ( > ) are from the debugger.

>Process 25199 (r.in.dem) stopped at [main:112 ,0x404a58]

This is the call about to be executed:
>112  read_dem_record(record[0], 1, 1, dem_ascii);

Here are the values that *should* be passed:
>(dbx) print record[1], 1, 1, dem_ascii 
>0x100354d8 1 1 0xfb52914 

Now the function is called:
>(dbx) S
>[5] calling read_dem_record(record = (nil), row = 0, col = 0,
>   dem_ascii = (nil)) from function main
>Process 25171 (r.in.dem) stopped at [read_dem_record:83 +0xc,0x404fec]

Note that the arguments passed to the function are *not* the values in those
variables immediately before the call.
**In trying to replicate this once more to be certain, it passed the values
correctly.**

-----------------------------------------------------------------------
Second: A function returns values, but they aren't assigned as the program
specifies.
Again, dbx lines are quoted.

>[8] Process 25208 (r.in.dem) stopped at [conv_row_ll2u:85 ,0x405b68]

This is the call about to be executed:
>  85  cell_row[0] = G_northing_to_row(north, cell_head);

Again, the values that should be passed:
>(dbx) print north, cell_head
>4540683.5292848777 0x7fffad48 

This time, they are passed correctly, and the function returns 1441.0:
>(dbx) S
>[14] calling G_northing_to_row(north = 4540683.5292848777,
>   window = 0x7fffad48) from function conv_row_ll2u
>Process 25208 (r.in.dem) stopped at [G_northing_to_row:123 ,0x40d9c4]
> 123  return (window->north - north) / window->ns_res;
>(dbx) S
>[14] G_northing_to_row returning 1441.0 from G_northing_to_row
>Process 25208 (r.in.dem) stopped  [conv_row_ll2u:85 +0x18,0x405b80]
>  85  cell_row[0] = G_northing_to_row(north, cell_head);

But now the assignment goofs:
(dbx) S
>[13] cell_row[0] changed before [conv_row_ll2u: line 85]:
>                new value = 1.0;
>Process 25208 (r.in.dem) stopped on watchpoint writing address
>  0x7fffacd4 [conv_row_ll2u:85 +0x2c,0x405b94]
---------------------------------------------------------------------------
This has me (and a professor) completely stumped. If you have any answers
or suggestions, please email me at ebuddington@wesleyan.edu.

Thanks,
Eric Buddington
Technical Details
Message-ID: <478q02$d1o@news.wesleyan.edu>
Path: arc1-ca.pugleaf.net!news.wesleyan.edu!detritus!eric

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!news.wesleyan.edu!detritus!eric
From: eric@detritus (Eric Buddington)
Newsgroups: comp.sys.sgi.apps,comp.lang.c
Subject: CC problem: passing/receiving values to functions
Date: 1 Nov 1995 21:48:50 GMT
Organization: Wesleyan University
Message-ID: <478q02$d1o@news.wesleyan.edu>
NNTP-Posting-Host: detritus.ees.wesleyan.edu
Keywords: ANSI C,CC,dbx
X-Newsreader: TIN [version 1.2 PL2]