Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 312711 - GCC -std=gnu89 (default) does not handle round() from math.h
Summary: GCC -std=gnu89 (default) does not handle round() from math.h
Status: RESOLVED INVALID
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: High normal (vote)
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-04-01 22:09 UTC by Jean-Francis Roy
Modified: 2010-10-26 10:45 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jean-Francis Roy 2010-04-01 22:09:19 UTC
I don't know if this is a bug or not, but it's a pretty strange behavior.

GCC still default to -std=gnu89 (until c99 is properly). On my box (see emerge --info below), including <math.h> does not provides the "round" function. It seems that it should be (it's working on several other systems... such as an x86_64 Ubuntu)

Please let me know if this is a bug or not. See bug #312463 for an example of a problem caused by this behavior.

Reproducible: Always

Steps to Reproduce:
1. gcc roundtest.c (will be attached)
2. gcc roundtest.c -std=gnu89
3. gcc roundtest.c -std=c99

Actual Results:  
1 and 2 fails, 3 succeed.

Expected Results:  
1 and 2 should succeed.

$ emerge --info
Portage 2.2_rc67 (default/linux/amd64/10.0/desktop/gnome, gcc-4.4.2, glibc-2.9_p20081201-r2, 2.6.33-gentoo x86_64)
=================================================================
System uname: Linux-2.6.33-gentoo-x86_64-Intel-R-_Core-TM-2_CPU_T5600_@_1.83GHz-with-gentoo-2.1.6
Timestamp of tree: Thu, 01 Apr 2010 06:00:14 +0000
distcc 3.1 x86_64-pc-linux-gnu [disabled]
app-shells/bash:     4.0_p35
dev-java/java-config: 2.1.10
dev-lang/python:     2.6.5-r1
dev-util/cmake:      2.8.1
sys-apps/baselayout: 2.1.6
sys-apps/openrc:     0.6.0
sys-apps/sandbox:    2.2
sys-devel/autoconf:  2.13, 2.65
sys-devel/automake:  1.8.5-r4, 1.9.6-r3, 1.10.3, 1.11.1
sys-devel/binutils:  2.19.1-r1
sys-devel/gcc:       4.4.2
sys-devel/gcc-config: 1.4.1
sys-devel/libtool:   2.2.6b
virtual/os-headers:  2.6.29
ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="*"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=core2 -O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/X11/xkb /usr/share/config"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c /etc/udev/rules.d"
CXXFLAGS="-march=core2 -O2 -pipe"
DISTDIR="/usr/portage/distfiles"
EMERGE_DEFAULT_OPTS="--jobs=3 --load-average=3.0 --with-bdeps y"
FEATURES="assume-digests distlocks fixpackages news parallel-fetch preserve-libs protect-owned sandbox sfperms strict unmerge-logs unmerge-orphans userfetch"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="en_CA.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--sort-common -Wl,--as-needed"
MAKEOPTS="-j3 -l3"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/var/lib/layman/sunrise /var/lib/layman/gnome /var/lib/layman/x11 /usr/local/portage/local-overlay"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="X a52 aac acl acpi alac alsa amd64 berkdb bluetooth branding bzip2 cairo cblas cddb cdr cleartype cli consolekit corefonts cracklib crypt cups cxx dbus dri dts dvd dvdr dvdread eds emboss encode evo exif faac fam ffmpeg firefox flac fortran gallium gdbm gif gnome gpm gsl gstreamer gtk hal iconv ipv6 irc jabber jpeg kde lame lapack latex lcms ldap libnotify mad mikmod mmx mng modules mp3 mp4 mpeg msn mudflap multilib ncurses networkmanager nls nptl nptlonly ogg opengl openmp pam pango pcre pdf perl png ppds pppd pulseaudio python qt3support qt4 quicktime readline reflection sdl semantic-desktop session sip spell spl sse sse2 ssl startup-notification subversion svg sysfs tcpd thunar tiff truetype type1 unicode usb vorbis wavpack webkit x264 xcb xml xorg xscreensaver xulrunner xv xvid zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" ELIBC="glibc" INPUT_DEVICES="evdev mouse keyboard joystick synaptics" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" RUBY_TARGETS="ruby18" USERLAND="GNU" VIDEO_CARDS="nvidia nouveau" 
Unset:  CPPFLAGS, CTARGET, FFLAGS, INSTALL_MASK, LC_ALL, LINGUAS, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 1 Chris Coleman 2010-04-03 04:21:22 UTC
I think you forgot to attach roundtest.c.

I think this is a bug in funtoo. I downloaded and extracted stage3-core2-2010.04.01.tar.bz2 and chrooted into it. Then:

$ echo -e '#include <math.h>\nint main() { round(1.1); }' > test.c
$ gcc -o test test.c
test.c: In function ‘main’:
test.c:2: warning: incompatible implicit declaration of built-in function ‘round’
$ gcc -std=gnu89 -o test test.c
test.c: In function ‘main’:
test.c:2: warning: incompatible implicit declaration of built-in function ‘round’
Comment 2 Chris Coleman 2010-04-03 05:17:31 UTC
It's not a bug. It's just that Funtoo is using an older version of glibc (2.9_p20081201-r2), before this was added:

#if (_POSIX_C_SOURCE - 0) >= 200112L
 # define __USE_XOPEN2K		1
+# undef __USE_ISOC99
+# define __USE_ISOC99		1
#endif
Comment 3 Chris Coleman 2010-04-03 05:19:02 UTC
(In reply to comment #2)
> #if (_POSIX_C_SOURCE - 0) >= 200112L
>  # define __USE_XOPEN2K         1
> +# undef __USE_ISOC99
> +# define __USE_ISOC99          1
> #endif
> 

in features.h.
Comment 4 Jean-Francis Roy 2010-04-04 01:40:01 UTC
Yep I actually forgot to attach roundtest.c. However, as Chris found out that was a Funtoo issue, I'm closing the bug with a resolution to INVALID.

Thanks for the help!