Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.compilers > #1669

Re: warning: assignment makes pointer from integer without a cast[enabled by default] yylval=atoi(yytext);

From Kaz Kylheku <330-706-9395@kylheku.com>
Newsgroups comp.compilers
Subject Re: warning: assignment makes pointer from integer without a cast[enabled by default] yylval=atoi(yytext);
Date 2016-02-24 15:56 +0000
Organization Aioe.org NNTP Server
Message-ID <16-02-006@comp.compilers> (permalink)
References <16-02-003@comp.compilers>

Show all headers | View raw


On 2016-02-22, Danny Pereira <dannyjpereira@gmail.com> wrote:
> *purelex.l:12:8: warning: assignment makes pointer from integer without a
> cast [enabled by default] yylval=atoi(yytext); *

This tells you that yylval does not have type int as you expect; it is
in fact a pointer to something.

Though presented as a "warning" in GCC, assigning an integer to a
pointer is a constraint violation according to ISO C, requiring a
diagnostic from a conforming implementation, and the behavior
is not well defined if the code is translated and executed anyway.

It is a bad idea to ignore this diagnostic.

Your yylval is a pointer because of the "Bison bridge" option.
This is documented in the GNU Flex manual:

  A.2 C Scanners with Bison Parsers

  [... few paragraphs down ...]

  Note that the macros `yylval' and `yylloc' evaluate to pointers.

Back to comp.compilers | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Re: warning: assignment makes pointer from integer without a cast[enabled by default] yylval=atoi(yytext); Danny Pereira <dannyjpereira@gmail.com> - 2016-02-22 09:28 +0530
  Re: warning: assignment makes pointer from integer without a cast[enabled by default] yylval=atoi(yytext); Kaz Kylheku <330-706-9395@kylheku.com> - 2016-02-24 15:56 +0000
  Re: warning: assignment makes pointer from integer without a cast[enabled by default] yylval=atoi(yytext); George Neuner <gneuner2@comcast.net> - 2016-02-24 13:07 -0500

csiph-web