Bug 163473 - ceil - incorrect undefined reference error
Summary: ceil - incorrect undefined reference error
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: gcc
Version: 4
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2005-07-18 00:01 UTC by Patrick
Modified: 2007-11-30 22:11 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2005-07-18 08:24:31 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Patrick 2005-07-18 00:01:46 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050524 Fedora/1.0.4-4 Firefox/1.0.4

Description of problem:
According to bytee in #fedora-ppc ceil(2.0/4.0) and ceil(.4) work correctly.
But if you say double c=.4; and did ceil(c), it would fail stating ceil.c:8: undefined reference to `ceil'. 


Version-Release number of selected component (if applicable):
gcc-4.0.0-8

How reproducible:
Always

Steps to Reproduce:
1. Get ztclock.c from http://www.xs4all.nl/~pjl/ztclock.c
2. gcc -I. -O3 -g -Wall ./ztclock.c -o ./ztclock
3. 
  

Actual Results:  /tmp/ccO1s5dm.o(.text+0x1a4): In function `main':
./ztclock.c:52: undefined reference to `ceilf'
collect2: ld returned 1 exit status

Expected Results:  Successful compilation.

Additional info:

If I remove the -O3 and compile I get:
/tmp/ccEzptmb.o(.text+0x2b8): In function `main':
./ztclock.c:52: undefined reference to `ceil'
collect2: ld returned 1 exit status
Note the search for "ceil" and not "ceilf"

If I compile with -lm the compilation is successful:
gcc -lm -I. -O3 -g -Wall ./ztclock.c -o ./ztclock

Comment 1 Jakub Jelinek 2005-07-18 08:24:31 UTC
And the bug is where?  -lm of course must be used when you use functions
implemented in libm.  Also, please learn to place libraries last on the command
line, otherwise things don't work very well at least when statically linking
or using nonshared auxiliary libraries (e.g. -lc or -lpthread have such aux
libs, -lm ATM doesn't, but that could change).


Note You need to log in before you can comment on or make changes to this bug.