Bug#749513: nethack: Conflicting parameter types to cause undefined behaviour

James Cowgill jcowgill at debian.org
Mon Mar 21 22:26:01 UTC 2016


Control: tags -1 moreinfo

Hi,

On Tue, 27 May 2014 16:15:07 +0100 Michael Tautschnig <mt at debian.org> wrote:
> Package: nethack
> Version: 3.4.3-15
> Usertags: goto-cc
> 
> During a rebuild of all Debian packages in a clean sid chroot (using cowbuilder
> and pbuilder) the build failed with the following error. Please note that we
> use our research compiler tool-chain (using tools from the cbmc package), which
> permits extended reporting on type inconsistencies at link time.
> 
> [...]
> gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wall -Wl,-z,relro -o nethack.console monst.o objects.o allmain.o alloc.o apply.o artifact.o attrib.o ball.o bones.o botl.o cmd.o dbridge.o decl.o detect.o dig.o display.o dlb.o do.o do_name.o do_wear.o dog.o dogmove.o dokick.o dothrow.o drawing.o dungeon.o eat.o end.o engrave.o exper.o explode.o extralev.o files.o fountain.o hack.o hacklib.o invent.o light.o lock.o mail.o makemon.o mapglyph.o mcastu.o mhitm.o mhitu.o minion.o mklev.o mkmap.o mkmaze.o mkobj.o mkroom.o mon.o mondata.o monmove.o monstr.o mplayer.o mthrowu.o muse.o music.o o_init.o objnam.o options.o pager.o pickup.o pline.o polyself.o potion.o pray.o priest.o quest.o questpgr.o read.o rect.o region.o restore.o rip.o rnd.o role.o rumors.o save.o shk.o shknam.o sit.o sounds.o sp_lev.o spell.o steal.o steed.o teleport.o timeout.o topten.o track.o trap.o u_init.o uhitm.o vault.o vision.o vis_tab.o weapon.o were.o wield.o windows.o wizard.o worm.o worn.o write.o zap.o  ioctl.o unixmain.o unixtty.o unixunix.o unixres.o getline.o termcap.o topl.o wintty.o cursmain.o curswins.o cursmisc.o cursdial.o cursstat.o cursinit.o cursmesg.o version.o -lncurses 
> 
> error: conflicting function declarations "check_leash"
> old definition in module allmain file ../include/extern.h line 41
> void (signed int, signed int)
> new definition in module apply file apply.c line 542
> void (signed char x, signed char y)

I believe this error is incorrect and is a bug in goto-cc rather than
in nethack.

The prototype in extern.h expands to:
 void check_leash(int, int);

The definition in apply.c expands to:
 void check_leash(x, y)
     char x, char y
 {
 ...

This is OK in standard C because old style K&R function definitions
have their parameters default promoted when calculating the type of the
function. Therefore the definition of check_leash in apply.c has the
type 'void (int, int)' and does not conflict with the prototype in
extern.h.

Relevant part of the C99 spec: section 6.7.5.3, paragraph 15.

James
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://lists.alioth.debian.org/pipermail/pkg-games-devel/attachments/20160321/0a1fa42a/attachment.sig>


More information about the Pkg-games-devel mailing list