Ruby 1.8.0 preview4

I get gobs of warnings when I build with gcc -Wall. I tried to send them to
the ML but the admin replied that my mail was too big. Do such warnings
interest you?

Solaris 9
gcc 3.2
iconv 1.8
readline 4.3

The most common were ones like these:

array.c:1461: warning: result' might be used uninitialized in this function bignum.c:450: warning: suggest parentheses around assignment used as truth value bignum.c:458: warning: subscript has type char’
dln.c:1307: warning: implicit declaration of function alloca' eval.c:7381: warning: umethod_unbind’ defined but not used
hash.c:531: warning: unused variable `i’ → lots and lots of unused variable
warnings throughout code

The library specific ones:
iconv.c: In function iconv_try': iconv.c:212: warning: passing arg 2 of libiconv’ from incompatible pointer
type

readline.c: In function readline_attempted_completion_function': readline.c:153: warning: subscript has type char’
readline.c:154: warning: subscript has type `char’

FWIW.

Regards,

Dan

···

-----Original Message-----
From: matz@ruby-lang.org [mailto:matz@ruby-lang.org]
Sent: Thursday, July 24, 2003 10:42 AM
To: ruby-talk@ruby-lang.org
Subject: Re: ruby 1.8.0 preview4

In message “Re: ruby 1.8.0 preview4” > on 03/07/24, Brian Candler B.Candler@pobox.com writes:

ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.0-preview4.tar.gz

I notice code is compiled with -g and not stripped. Looking
at 1.6.8 it
seems to be the same, so I guess this is intentional.

Strange. It has not changed since 1.6.8; it should be
compiled with “-g -O2” by default, without stripping.

  					matz.

More on preview4 warnings:
I’m posting here because I can’t see the root message.

Preview4 builds on hp/compaq tru64 (osf1) 5.1.
I get many many warnings.
Most are signed/unsigned pointer type errors, like this one:
cc -ieee -g -oldc -std -I. -I. -c array.c
type of the p
ointer value “&v” is “unsigned long”, which is not compatible with
"long" becaus
e they differ by signed/unsigned attribute. (ptrmismatch1)
if (st_delete(RHASH(hash)->tbl, &v, 0)) {
----------------------------------------^
There are 95 warnings of this type (ptrmismatch1).

There are 24 Warning: Unresolved: linkage warnings, which I guess
should just be ignored.

There are 6 more warnings left:
1)
cc -ieee -g -oldc -std -I. -I. -c file.c
does not co
ntain a return statement. (missingreturn)
static VALUE
^
2)
cc -ieee -g -oldc -std -I. -I. -c process.c
does not
contain a return statement. (missingreturn)
static VALUE
^
3)
cc -ieee -g -oldc -std -I. -I/u13/home/doug/ruby/ruby-1.8.0
-I/u13/home/doug/rub
y/ruby-1.8.0 -I/u13/home/doug/ruby/ruby-1.8.0/ext/curses
-DHAVE_CURSES_H -DHAVE_
ISENDWIN -DHAVE_UNGETCH -DHAVE_BEEP -DHAVE_GETNSTR -DHAVE_WGETNSTR
-DHAVE_DOUPDA
TE -DHAVE_FLASH -DHAVE_DELETELN -DHAVE_WDELETELN -DHAVE_KEYPAD
-DHAVE_KEYNAME -D
HAVE_INIT_COLOR -c curses.c
type “int”
, is being converted to “pointer to const char”. (cvtdiftypes)
name = keyname(NUM2INT©);
–^
4)
cc -Dsocklen_t=int -DHAVE_GETADDRINFO -DHAVE_SOCKADDR_STORAGE -DINET6
-ieee -g -
oldc -std -DENABLE_IPV6 -I. -I/u13/home/doug/ruby/ruby-1.8.0
-I/u13/home/doug/ru
by/ruby-1.8.0 -I/u13/home/doug/ruby/ruby-1.8.0/ext/socket
-DHAVE_NETINET_TCP_H -
DHAVE_NETINET_UDP_H -DHAVE_ST_MSG_ACCRIGHTS -DHAVE_GETADDRINFO
-DHAVE_GETNAMEINF
O -DHAVE_SYS_UN_H -DHAVE_SYS_UIO_H -DHAVE_SOCKET -DHAVE_GETHOSTNAME
-c socket.c
fetched but not
initialized. And there may be other such fetches of this variable
that have not
been reported in this compilation. (uninit1)
memcpy((char*)&sin6.sin6_addr, *pch, size);
-------------------------------------------------^
5)
cc -ieee -g -oldc -std -I. -I/u13/home/doug/ruby/ruby-1.8.0
-I/u13/home/doug/rub
y/ruby-1.8.0 -I/u13/home/doug/ruby/ruby-1.8.0/ext/syck -DHAVE_ST_H -c
emitter.c
sprintf co
ntains a bad conversion specification “%Y” that will cause
unpredictable behavio
r. (badconvspec)
sprintf( header, "— %YAML:%d.%d ", SYCK_YAML_MAJOR,
SYCK_YAML_MINO
R );
-----------------------------^
6)
cc -ieee -g -oldc -std -I. -I/u13/home/doug/ruby/ruby-1.8.0
-I/u13/home/doug/rub
y/ruby-1.8.0 -I/u13/home/doug/ruby/ruby-1.8.0/ext/tcltklib
-DHAVE_TCL_H -DHAVE_T
K_H -c stubs.c
declarations. (e
mptyfile)
#endif
------^

Of these warnings, only number 4(uninitialized) and 5(bad conversion)
scare me.

Should I investigate these, or just ignore them?

Doug

···

cc: Warning: array.c, line 1820: In this statement, the referenced
cc: Warning: file.c, line 1048: Non-void function "rb_file_s_lchmod"
cc: Warning: process.c, line 1478: Non-void function "p_sys_issetugid"
cc: Warning: curses.c, line 434: In this statement, “keyname(…)” of
cc: Warning: socket.c, line 1127: The scalar variable “size” is
cc: Warning: emitter.c, line 174: In this statement, this argument to
cc: Warning: stubs.c, line 94: Source file does not contain any

Hi,

cc: Warning: array.c, line 1820: In this statement, the referencedtype of the pointer value “&v” is “unsigned long”, which is not compatible with"long" because they differ by signed/unsigned attribute. (ptrmismatch1)
if (st_delete(RHASH(hash)->tbl, &v, 0)) {
----------------------------------------^
There are 95 warnings of this type (ptrmismatch1).

They are harmless. I think I can pacify them.

There are 6 more warnings left:
1)
cc -ieee -g -oldc -std -I. -I. -c file.c
cc: Warning: file.c, line 1048: Non-void function “rb_file_s_lchmod”
does not co
ntain a return statement. (missingreturn)
static VALUE

Fixed.

cc -ieee -g -oldc -std -I. -I. -c process.c
cc: Warning: process.c, line 1478: Non-void function “p_sys_issetugid”
does not
contain a return statement. (missingreturn)
static VALUE

Fixed.

cc -ieee -g -oldc -std -I. -I/u13/home/doug/ruby/ruby-1.8.0
-I/u13/home/doug/rub
y/ruby-1.8.0 -I/u13/home/doug/ruby/ruby-1.8.0/ext/curses
-DHAVE_CURSES_H -DHAVE_
ISENDWIN -DHAVE_UNGETCH -DHAVE_BEEP -DHAVE_GETNSTR -DHAVE_WGETNSTR
-DHAVE_DOUPDA
TE -DHAVE_FLASH -DHAVE_DELETELN -DHAVE_WDELETELN -DHAVE_KEYPAD
-DHAVE_KEYNAME -D
HAVE_INIT_COLOR -c curses.c
cc: Warning: curses.c, line 434: In this statement, “keyname(…)” of
type “int”
, is being converted to “pointer to const char”. (cvtdiftypes)
name = keyname(NUM2INT(c));
–^

I don’t understand. this means configure found ‘keyname’ from your
curses library, but it is not declared in the header files. Strange.

cc -Dsocklen_t=int -DHAVE_GETADDRINFO -DHAVE_SOCKADDR_STORAGE -DINET6
-ieee -g -
oldc -std -DENABLE_IPV6 -I. -I/u13/home/doug/ruby/ruby-1.8.0
-I/u13/home/doug/ru
by/ruby-1.8.0 -I/u13/home/doug/ruby/ruby-1.8.0/ext/socket
-DHAVE_NETINET_TCP_H -
DHAVE_NETINET_UDP_H -DHAVE_ST_MSG_ACCRIGHTS -DHAVE_GETADDRINFO
-DHAVE_GETNAMEINF
O -DHAVE_SYS_UN_H -DHAVE_SYS_UIO_H -DHAVE_SOCKET -DHAVE_GETHOSTNAME
-c socket.c
cc: Warning: socket.c, line 1127: The scalar variable “size” is
fetched but not
initialized. And there may be other such fetches of this variable
that have not
been reported in this compilation. (uninit1)
memcpy((char*)&sin6.sin6_addr, *pch, size);
-------------------------------------------------^

This was a important bug. Thank you.

cc -ieee -g -oldc -std -I. -I/u13/home/doug/ruby/ruby-1.8.0
-I/u13/home/doug/rub
y/ruby-1.8.0 -I/u13/home/doug/ruby/ruby-1.8.0/ext/syck -DHAVE_ST_H -c
emitter.c
cc: Warning: emitter.c, line 174: In this statement, this argument to
sprintf co
ntains a bad conversion specification “%Y” that will cause
unpredictable behavio
r. (badconvspec)
sprintf( header, "— %YAML:%d.%d ", SYCK_YAML_MAJOR,
SYCK_YAML_MINO
R );

Fixed.

cc -ieee -g -oldc -std -I. -I/u13/home/doug/ruby/ruby-1.8.0
-I/u13/home/doug/rub
y/ruby-1.8.0 -I/u13/home/doug/ruby/ruby-1.8.0/ext/tcltklib
-DHAVE_TCL_H -DHAVE_T
K_H -c stubs.c
cc: Warning: stubs.c, line 94: Source file does not contain any
declarations. (e
mptyfile)
#endif
------^

This is OK, just ignore.

						matz.
···

In message “Re: ruby 1.8.0 preview4” on 03/07/25, the_rev_dharma_roadkill doug.hendricks@tnzi.com writes:

Here are what IMO are the important warnings from FreeBSD-4.8, gcc version
2.95.4 20020320

gcc -fPIC -g -O2 -Wall -fno-defer-pop -fno-omit-frame-pointer -I. -I/v/build/ruby/ruby-1.8.0 -I/v/build/ruby/ruby-1.8.0 -I/v/build/ruby/ruby-1.8.0/ext/dl -DHAVE_DLFCN_H -DHAVE_DLOPEN -DHAVE_DLCLOSE -DHAVE_DLSYM -DHAVE_DLERROR -I. -c dl.c
dl.c: In function rb_ary_to_ptr': dl.c:522: warning:ptr’ might be used uninitialized in this function
[I reckon it should be initialised to NULL]

gcc -fPIC -DHAVE_GETADDRINFO -DHAVE_SA_LEN -DHAVE_SOCKADDR_STORAGE -DHAVE_SIN_LEN -DINET6 -g -O2 -Wall -DENABLE_IPV6 -I. -I/v/build/ruby/ruby-1.8.0 -I/v/build/ruby/ruby-1.8.0 -I/v/build/ruby/ruby-1.8.0/ext/socket -DHAVE_NETINET_TCP_H -DHAVE_NETINET_UDP_H -DHAVE_ST_MSG_CONTROL -DHAVE_GETADDRINFO -DHAVE_GETNAMEINFO -DHAVE_SYS_UN_H -DHAVE_SYS_UIO_H -DHAVE_SOCKET -DHAVE_GETHOSTNAME -c socket.c
socket.c: In function tcp_s_gethostbyname': socket.c:1095: warning:size’ might be used uninitialized in this function
[fixed already I think]

And here are some missing #include’s, plus a couple of possible missing
initialisations:

gcc -g -O2 -Wall -I. -I. -c regex.c
regex.c: In function ruby_re_compile_pattern': regex.c:1472: warning: implicit declaration of functionrb_warn’

gcc -fPIC -g -O2 -Wall -I. -I/v/build/ruby/ruby-1.8.0 -I/v/build/ruby/ruby-1.8.0 -I/v/build/ruby/ruby-1.8.0/ext/pty -DHAVE_SETRESUID -DHAVE_LIBUTIL_H -DHAVE_OPENPTY -c pty.c
pty.c: In function pty_finalize_syswait': pty.c:304: warning: implicit declaration of functionrb_detach_process’

gcc -fPIC -g -O2 -Wall -DREADLINE_40_OR_LATER -DREADLINE_21_OR_LATER -I. -I/v/build/ruby/ruby-1.8.0 -I/v/build/ruby/ruby-1.8.0 -I/v/build/ruby/ruby-1.8.0/ext/readline -DHAVE_READLINE_READLINE_H -DHAVE_READLINE_HISTORY_H -DHAVE_RL_CLEANUP_AFTER_SIGNAL -c readline.c
readline.c: In function readline_readline': readline.c:51: warning: implicit declaration of functionisatty’

gcc -fPIC -g -O2 -Wall -I. -I/v/build/ruby/ruby-1.8.0 -I/v/build/ruby/ruby-1.8.0 -I/v/build/ruby/ruby-1.8.0/ext/syck -DHAVE_ST_H -c handler.c
handler.c: In function syck_add_transfer': handler.c:109: warning: implicit declaration of functionfree’
handler.c: In function syck_xprivate': handler.c:125: warning: implicit declaration of functionmalloc’
handler.c:127: warning: implicit declaration of function strcat' handler.c:128: warning: implicit declaration of functionstrncat’
gcc -fPIC -g -O2 -Wall -I. -I/v/build/ruby/ruby-1.8.0 -I/v/build/ruby/ruby-1.8.0 -I/v/build/ruby/ruby-1.8.0/ext/syck -DHAVE_ST_H -c node.c
node.c: In function syck_alloc_node': node.c:20: warning: implicit declaration of functionmalloc’
node.c: In function syck_free_node': node.c:35: warning: implicit declaration of functionfree’
node.c: In function syck_str_blow_away_commas': node.c:124: warning: implicit declaration of functionmemmove’
node.c: In function syck_map_add': node.c:163: warning: implicit declaration of functionrealloc’
gcc -fPIC -g -O2 -Wall -I. -I/v/build/ruby/ruby-1.8.0 -I/v/build/ruby/ruby-1.8.0 -I/v/build/ruby/ruby-1.8.0/ext/syck -DHAVE_ST_H -c rubyext.c
rubyext.c: In function rb_syck_mktime': rubyext.c:160: warning: implicit declaration of functionisdigit’
rubyext.c: In function rb_syck_parse_handler': rubyext.c:237: warning:v’ might be used uninitialized in this function
rubyext.c: In function rb_syck_load_handler': rubyext.c:314: warning:obj’ might be used uninitialized in this function
rubyext.c: In function syck_loader_transfer': rubyext.c:861: warning:domain’ might be used uninitialized in this function
rubyext.c: In function syck_emitter_simple_write': rubyext.c:1135: warning: implicit declaration of functionsyck_emitter_simple’
gcc -fPIC -g -O2 -Wall -I. -I/v/build/ruby/ruby-1.8.0 -I/v/build/ruby/ruby-1.8.0 -I/v/build/ruby/ruby-1.8.0/ext/syck -DHAVE_ST_H -c syck.c
syck.c: In function syck_strndup': syck.c:35: warning: implicit declaration of functionmalloc’
syck.c: In function syck_free_parser': syck.c:244: warning: implicit declaration of functionfree’
syck.c: In function syck_parser_add_level': syck.c:359: warning: implicit declaration of functionrealloc’
syck.c: In function syck_parse': syck.c:486: warning: implicit declaration of functionyyparse’
gcc -fPIC -g -O2 -Wall -I. -I/v/build/ruby/ruby-1.8.0 -I/v/build/ruby/ruby-1.8.0 -I/v/build/ruby/ruby-1.8.0/ext/syck -DHAVE_ST_H -c emitter.c
emitter.c: In function syck_new_emitter': emitter.c:30: warning: implicit declaration of functionmalloc’
emitter.c: In function syck_st_free_anchors': emitter.c:58: warning: implicit declaration of functionfree’
emitter.c: In function syck_emitter_flush': emitter.c:174: warning: unknown conversion type characterY’ in format
[this last one has also been fixed already I think]

Regards,

Brian.

matz@ruby-lang.org (Yukihiro Matsumoto) wrote in message news:1059109829.620029.4067.nullmailer@picachu.netlab.jp

[Much snipped]

cc -ieee -g -oldc -std -I. -I/u13/home/doug/ruby/ruby-1.8.0
-I/u13/home/doug/rub
y/ruby-1.8.0 -I/u13/home/doug/ruby/ruby-1.8.0/ext/curses
-DHAVE_CURSES_H -DHAVE_
ISENDWIN -DHAVE_UNGETCH -DHAVE_BEEP -DHAVE_GETNSTR -DHAVE_WGETNSTR
-DHAVE_DOUPDA
TE -DHAVE_FLASH -DHAVE_DELETELN -DHAVE_WDELETELN -DHAVE_KEYPAD
-DHAVE_KEYNAME -D
HAVE_INIT_COLOR -c curses.c
cc: Warning: curses.c, line 434: In this statement, “keyname(…)” of
type “int”
, is being converted to “pointer to const char”. (cvtdiftypes)
name = keyname(NUM2INT(c));
–^

I don’t understand. this means configure found ‘keyname’ from your
curses library, but it is not declared in the header files. Strange.

It is because _XOPEN_SOURCE_EXTENDED is not set before accessing
curses.h. I’m not sure if I care or not. If we set it explicitly,
something else will probably break!

cc: Warning: socket.c, line 1127: The scalar variable “size” is
fetched but not
initialized. And there may be other such fetches of this variable
that have not
been reported in this compilation. (uninit1)
memcpy((char*)&sin6.sin6_addr, *pch, size);
-------------------------------------------------^

This was a important bug. Thank you.

And Thank You. You have just made my day. I am glad to be of service
to a beautiful programming language.

  					matz.

Doug

Hello,

socket.c: In function tcp_s_gethostbyname': socket.c:1095: warning: size’ might be used uninitialized in this function
[fixed already I think]

Fixed.

regex.c: In function ruby_re_compile_pattern': regex.c:1472: warning: implicit declaration of function rb_warn’

Fixed.

pty.c: In function pty_finalize_syswait': pty.c:304: warning: implicit declaration of function rb_detach_process’

Fixed. To be checked in soon.

readline.c: In function readline_readline': readline.c:51: warning: implicit declaration of function isatty’

Do you mean isatty(3) is not declared in <unistd.h> on FreeBSD?

gcc -fPIC -g -O2 -Wall -I. -I/v/build/ruby/ruby-1.8.0 -I/v/build/ruby/ruby-1.8.0 -I/v/build/ruby/ruby-1.8.0/ext/syck -DHAVE_ST_H -c handler.c

I think _Why will work on those.

						matz.
···

In message “Re: ruby 1.8.0 preview4” on 03/07/25, Brian Candler B.Candler@pobox.com writes:

As we speak… Thanks for fixing the sprintf one, matz.

_why

···

On Friday 25 July 2003 10:43 am, Yukihiro Matsumoto wrote:

I think _Why will work on those.

  					matz.

No, it is declared there. I think the problem is here:

#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif

but config.h (via ruby.h) has not been included at that point, so unistd.h
is not being included.

Regards,

Brian.

···

On Sat, Jul 26, 2003 at 01:43:52AM +0900, Yukihiro Matsumoto wrote:

readline.c: In function readline_readline': readline.c:51: warning: implicit declaration of function isatty’

Do you mean isatty(3) is not declared in <unistd.h> on FreeBSD?

FreeBSD does spend some effort to minimize namespace pollution,
such that symbols from one include library (such as unistd.h)
will not show up when some other library is included, unless
the standards say those symbols must show up. And even then,
we try to only bring in the symbols that must be brought in,
and not the entire include file.

So, in other OS’s you could very well bring in the symbols
you want from unistd.h (or even all of unistd.h) even if
you never explicitly #include it.

···

At 7:11 AM +0900 7/26/03, Brian Candler wrote:

On Sat, Jul 26, 2003, Yukihiro Matsumoto wrote:

readline.c: In function readline_readline': readline.c:51: warning: implicit declaration of function isatty’

Do you mean isatty(3) is not declared in <unistd.h> on FreeBSD?

No, it is declared there. I think the problem is here:

#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif

but config.h (via ruby.h) has not been included at that point,
so unistd.h is not being included.


Garance Alistair Drosehn = gad@gilead.netel.rpi.edu
Senior Systems Programmer or gad@freebsd.org
Rensselaer Polytechnic Institute or drosih@rpi.edu

Hi,

···

In message “Re: ruby 1.8.0 preview4” on 03/07/26, Brian Candler B.Candler@pobox.com writes:

readline.c: In function readline_readline': readline.c:51: warning: implicit declaration of function isatty’

Do you mean isatty(3) is not declared in <unistd.h> on FreeBSD?

No, it is declared there. I think the problem is here:

#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif

but config.h (via ruby.h) has not been included at that point, so unistd.h
is not being included.

Aha! Thanks a lot.

						matz.