This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

c++/4225: bad reference in an object file caused by the include method



>Number:         4225
>Category:       c++
>Synopsis:       bad reference in an object file caused by the include method
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Tue Sep 04 08:26:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Armand Betton
>Release:        gcc 3.0.1
>Organization:
>Environment:
Reading specs from /home/dsv5/packages/gcc-3.0.1/lib/gcc-lib/sparc-sun-solaris2.
7/3.0.1/specs
Configured with: /tmcenter/navis/ccpkg/data/gcc-3.0.1/configure --prefix=/home/d
sv5/packages/gcc-3.0.1 --enable-languages=c++,java --enable-shared --enable-thre
ads --with-gnu-ld --with-ld=/home/dsv5/packages/binutils-2.11.2/bin/ld --with-gn
u-as --with-as=/home/dsv5/packages/binutils-2.11.2/bin/as
Thread model: posix
gcc version 3.0.1
>Description:
1- An .h file declaring a C++ function

/tmp/foo/foo.h

<<
void foo(int x);
>How-To-Repeat:
See description.
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
 >>
 
 2- A C++ source including the .h file and calling the function
 
 /tmp/foo.c
 
 <<
 #include "foo.h"
 
 int main(void)
 {
     foo(0);
 }
 >>
 
 3- First compilation using "-I" option
 
 CPLUS_INCLUDE_PATH=
 export CPLUS_INCLUDE_PATH
 gcc -ggdb -c -I/tmp/foo -o foo.o -x c++ foo.c
 nm -C foo.o
 
 <<
 0000000000000000 a *ABS*
                  U foo(int)
 0000000000000000 ? __FRAME_BEGIN__
                  U __gxx_personality_v0
 0000000000000000 T main
 >>
 
 the "foo" function is referenced as a mangled c++ function reference
 
 4- Second compilation (not using the -I option)
 
 CPLUS_INCLUDE_PATH=/tmp/foo
 export CPLUS_INCLUDE_PATH
 gcc -ggdb -c -o foo.o -x c++ foo.c
 nm -C foo.o
 
 <<
 0000000000000000 a *ABS*
 0000000000000000 ? __FRAME_BEGIN__
                  U __gxx_personality_v0
                  U foo
 0000000000000000 T main
 >>
 
 The "foo" function is now referenced as a "C" (instead of C++) function.
 
 This is a dummy example ; in a real case, the "foo" function is defined in an external library ; the "link" stage cause an "undefined reference foo(int)".
 
 
----gnatsweb-attachment----
Content-Type: application/x-gzip-compressed; name="foo.tgz"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="foo.tgz"

H4sIAPPulDsAA+3UvW7CMBRAYa/1U1h0gQWug38GniaCVlhqkgoMQkK8OzGtYEOq1ITlfIsHW/Id
fJyb78Vn183XajhiRYITJVJ5511ZnXNVv/7yQUlcOm+Dr2Lsz1vrozIy4Ex3h32ud8aotj6m/ZNz
uRljmtG9p3b9ddh8mEl5BduJ1qnNpqlTOz12aTPTZ/3W70xlttIX/epp8d/yT/+3P2A70B2l/+if
9F/ZR//Bl/7jMtD/GErkpgResj/1kb96IAAAAAAAAAAAAAAAAPzJFes+Gw0AKAAA


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]