[Bug 1758373] Re: bison -Wconversion warning
Amr Ibrahim
1758373 at bugs.launchpad.net
Fri Mar 23 17:17:32 UTC 2018
In the future, please use `ubuntu-bug package-name` to report bugs. Thanks.
https://help.ubuntu.com/dev/ubuntu-help/report-ubuntu-bug.html.en
** Package changed: gnome-settings-daemon (Ubuntu) => bison (Ubuntu)
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to bison in Ubuntu.
https://bugs.launchpad.net/bugs/1758373
Title:
bison -Wconversion warning
Status in bison package in Ubuntu:
New
Bug description:
I wish to use the -Wconversion at gcc (the warnings are instructive
for me, and they already taught me a lot), but then:
$ bash bison_conversion_bug.sh
y.tab.c: In function ‘yyparse’:
y.tab.c:1023:12: warning: conversion to ‘yytype_int16 {aka short int}’ from ‘int’ may alter its value [-Wconversion]
*yyssp = yystate;
^~~~~~~
y.tab.c:1028:25: warning: conversion to ‘long unsigned int’ from ‘long int’ may change the sign of the result [-Wsign-conversion]
YYSIZE_T yysize = yyssp - yyss + 1;
^~~~~
$
I get this problem even in an almost empty grammar and minimal C
source frame for it, see the attachment: an example for minimal
grammar and minimal C frame ALREADY providing the error.
This is the error in case of my Ubuntu 18.04 ( bison --version =
3.0.4, gcc --version = (Ubuntu 7.3.0-12ubuntu1) 7.3.0).
I could try Debian jessie, where I get exactly the same error at
exactly the same line position ( bison --version = 3.0.2, gcc
--version = (Debian 4.9.2-10+deb8u1) 4.9.2).
MY SUGGESTION: IF the bison developers are sure, that "yystate" and
"yyssp - yyss + 1" will always fit into "short int" or "long unsigned
int", THEN an explicit casting could be a solution. HOWEVER in case
of "yystate" it would be much more relaxing to make a decision whether
it should be an "int" or "short int".
The compilation commands are:
CCOPTS=''
CCOPTS+=' -std=c11'
CCOPTS+=' -Og -g'
CCOPTS+=' -Wabi'
CCOPTS+=' -Wfatal-errors'
CCOPTS+=' -Wall'
CCOPTS+=' -Wextra'
CCOPTS+=' -Wreturn-type'
CCOPTS+=' -Wconversion' ### bison has 2 conversion errors
CCOPTS+=' -fexceptions'
CCOPTS+=' -pedantic-errors'
CCOPTS+=' -fmax-errors=1'
rm -f y.output y.tab.h y.tab.c y.tab.o
bison --yacc --verbose -d "EXAMPLE_GIVEN_IN_THE_ATTACHMENT.y"
gcc -c ${CCOPTS} y.tab.c
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/bison/+bug/1758373/+subscriptions
More information about the foundations-bugs
mailing list