bison -Wconversion warning
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
bison (Ubuntu) |
New
|
Undecided
|
Unassigned |
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_conversio
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_
gcc -c ${CCOPTS} y.tab.c
HELP! I adjusted at the beginning of the bug report, that this is NOT a gnome-settings- daemon bug, BUT a bison bug, ... there was a possibility TO CHANGE THE PACKAGE WHAT IS AFFECTED, I do not know why it changed back to gnome-settings- daemon?
Please, somebody who has enough right for this, change it to bison. Thanks.