comp.lang.ada
 help / color / mirror / Atom feed
From: "Björn Persson" <spam-away@nowhere.nil>
Subject: Re: STORAGE_ERROR in adainit
Date: Tue, 17 Aug 2004 21:37:11 GMT
Date: 2004-08-17T21:37:11+00:00	[thread overview]
Message-ID: <bUuUc.101141$dP1.352925@newsc.telia.net> (raw)
In-Reply-To: <okgph05u5lf5eeiemg4vp9agvu6akvp4im@4ax.com>

James Alan Farrell wrote:

> On Thu, 12 Aug 2004 21:15:01 GMT, Björn Persson
> <spam-away@nowhere.nil> wrote:
> 
>>James Alan Farrell wrote:
>>
>>>I think I've found the problem:
>>>
>>>There was a function in a C library called program_error.  I changed
>>>the name to a_program_error and the storage_error went away.
>>
>>It's probably a bug in your compiler that it doesn't detect the name 
>>clash. GCC-Gnat 3.4 detects it in the following test case:
> 
> Does it detect the problem if the main in C and Clash_Test_Ada is
> exported to C?   That is the problem I am having.  I suspect what you
> show here is easier for the compiler to detect than the other way
> around.

Yes, I get the same error messages when the main program is in C:


file clash_test_2_ada.ads:

package Clash_Test_2_Ada is
end Clash_Test_2_Ada;


file clash_test_2_c.c:

void program_error() {}

int main(int argc, char** argv) {
    adainit();
    program_error();
    adafinal();
    return 0;
}


$ gcc -c clash_test_2_c.c
$ gnatmake clash_test_2_ada
gcc -c clash_test_2_ada.ads
$ gnatbind -n clash_test_2_ada.ali
$ LANG=en_US gnatlink clash_test_2_ada.ali clash_test_2_c.o
/home/bjorn/ada/gcc-3.4.0-inst/lib/gcc/i686-pc-linux-gnu/3.4.0/adalib/libgnat.a(s-stalib.o)(.data+0x78):/home/bjorn/ada/gcc-3.4.0-objdir/gcc/ada/rts/s-stalib.adb:104: 
multiple definition of `program_error'
clash_test_2_c.o(.text+0x0): first defined here
/usr/bin/ld: Warning: size of symbol `program_error' changed from 5 in 
clash_test_2_c.o to 24 in 
/home/bjorn/ada/gcc-3.4.0-inst/lib/gcc/i686-pc-linux-gnu/3.4.0/adalib/libgnat.a(s-stalib.o)
/usr/bin/ld: Warning: type of symbol `program_error' changed from 2 to 1 
in 
/home/bjorn/ada/gcc-3.4.0-inst/lib/gcc/i686-pc-linux-gnu/3.4.0/adalib/libgnat.a(s-stalib.o)
collect2: ld returned 1 exit status
gnatlink: cannot call /home/bjorn/ada/gcc-3.4.0-inst/bin/gcc


> I found the problem by creating a small test program.  When I did that
> I got a linker warning pointing to program_error (indicating in fact
> that it is used as data in one place and as a function in another
> place).

So the difference is that you get a warning but an executable is 
produced, while for me, Gnatlink treats the clash as a fatal error and 
refuses to produce an executable.

> In the production program I am getting an unrelated linker warning,
> but I think for some reason that warning was preventing the warning
> that I needed from being displayed.

While I don't know what that warning is about, I'd recommend that you 
fix it. It may well be another fatal error.

-- 
Björn Persson                              PGP key A88682FD
                    omb jor ers @sv ge.
                    r o.b n.p son eri nu




  reply	other threads:[~2004-08-17 21:37 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-11 21:31 STORAGE_ERROR in adainit James Alan Farrell
2004-08-11 22:29 ` Marc A. Criley
2004-08-12 13:35   ` James Alan Farrell
2004-08-12 14:20     ` Frode Tenneboe
2004-08-12 15:55       ` James Alan Farrell
2004-08-12 21:17         ` Björn Persson
2004-08-12 19:28 ` James Alan Farrell
2004-08-12 19:42   ` Ludovic Brenta
2004-08-12 22:10     ` Stephen Leake
2004-08-12 21:15   ` Björn Persson
2004-08-13 13:36     ` James Alan Farrell
2004-08-17 21:37       ` Björn Persson [this message]
2004-08-18 14:00         ` James Alan Farrell
2004-08-18 15:57           ` Björn Persson
2004-08-18 19:44           ` Simon Wright
2004-08-18 21:13             ` James Alan Farrell
replies disabled

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