Article View: gnu.g++.bug
Article #944compiler warning, link problems
From: Bradley D. Keister
Date: Fri, 11 Sep 1992 06:10
Date: Fri, 11 Sep 1992 06:10
62 lines
1831 bytes
1831 bytes
I'm running g++ 2.2.2 on a DECstation 3100 and a Sun SPARC, and am
having trouble with the following code:
--------------
#include <stdio.h>
#include <math.h>
#include <Complex.h>
double test()
{
Complex trash(4, 5);
// Complex throwaway[2][2];
return trash.real();
}
main()
{
printf("4?: %8.2f\n", test());
return 0;
}
--------------
If I uncomment the array declaration, then I get a compiler warning:
trash.c: In function `double test ()':
trash.c:10: warning: control reaches end of non-void function
With the line commented out, there is no warning.
Furthermore, whether or not the array declaration is commented, the
linker either refuses to or can't find the math library (it's there -
I just built some other code which uses it extensively):
% g++ -o trash trash.c -lm
// trash.c: In function `double test ()':
// trash.c:10: warning: control reaches end of non-void function
ld:
Undefined:
hypot
atan2
cos
sin
exp
cosh
sinh
log
pow
sqrt
collect: /usr/bin/ld returned 1 exit status
I don't know at this point what sort of code is generated alongside
the warning.
Brad Keister
Department of Physics
Carnegie Mellon University
Pittsburgh, PA 15213
(412) 268-2772 (office)
(412) 681-0648 (FAX)
internet: keister@poincare.phys.cmu.edu
BITNET: keister%poincare.phys.cmu.edu@CARNEGIE
Technical Details
Message-ID:
<9209111410.AA10780@poincare.phys.cmu.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!elroy.jpl.nasa.gov!swrinde!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!poincare.phys.cmu.edu!keisterShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!elroy.jpl.nasa.gov!swrinde!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!poincare.phys.cmu.edu!keister From: keister@poincare.phys.cmu.edu (Bradley D. Keister) Newsgroups: gnu.g++.bug Subject: compiler warning, link problems Message-ID: <9209111410.AA10780@poincare.phys.cmu.edu> Date: 11 Sep 92 06:10:18 GMT Sender: gnulists@ai.mit.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 62 Approved: bug-g++@prep.ai.mit.edu