bison -Wconversion warning

Bug #1758373 reported by Péter Prőhle
6
This bug affects 1 person
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_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

Revision history for this message
Péter Prőhle (prohlep) wrote :
Revision history for this message
Péter Prőhle (prohlep) wrote :

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.

Revision history for this message
Amr Ibrahim (amribrahim1987) wrote :

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

affects: gnome-settings-daemon (Ubuntu) → bison (Ubuntu)
Revision history for this message
Péter Prőhle (prohlep) wrote : Re: [Bug 1758373] Re: bison -Wconversion warning

> 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

Many thanks, not only for the help in changing the package for the report,
but also for your comment, INDEED, it is much more simple to use the
"ubuntu-bug package-name", thanks!

Péter.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.