Skip to content

Implicit type conversion warnings #196

@ruimaciel

Description

@ruimaciel

While building re2c from source (v1.0.2) I've noticed that there are a couple of type conversion warnings popping out during the build process. Here are the warnings:

Warning #1:

rc/ast/parser.cc: In function ‘int yyparse(re2c::context_t&)’:
src/ast/parser.cc:1128:10: warning: conversion to ‘yytype_int16 {aka short int}’ from ‘int’ may alter its value [-Wconversion]
   *yyssp = yystate;
          ^

Here's a proposal to fix this warning, by changing the type of yystate (and yyn) to yytype_int16.
patch1.txt

Warning #2:

src/ast/parser.cc:1133:40: warning: conversion to ‘long unsigned int’ from ‘long int’ may change the sign of the result [-Wsign-conversion]
       YYSIZE_T yysize = yyssp - yyss + 1;

This warning, OTOH, may require some attention, as YYSIZE_T is an unsigned integer type but I believe there are no assurances that the result of (yyssp-yyss + 1) is always positive.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions