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

Kaz Kylheku <330-706-9395@kylheku.com>
Wed, 24 Feb 2016 15:56:17 +0000 (UTC)

          From comp.compilers

Related articles
Re: warning: assignment makes pointer from integer without a cast[enab dannyjpereira@gmail.com (Danny Pereira) (2016-02-22)
Re: warning: assignment makes pointer from integer without a cast[enab 330-706-9395@kylheku.com (Kaz Kylheku) (2016-02-24)
Re: warning: assignment makes pointer from integer without a cast[enab gneuner2@comcast.net (George Neuner) (2016-02-24)
| List of all articles for this month |

From: Kaz Kylheku <330-706-9395@kylheku.com>
Newsgroups: comp.compilers
Date: Wed, 24 Feb 2016 15:56:17 +0000 (UTC)
Organization: Aioe.org NNTP Server
References: 16-02-003
Injection-Info: miucha.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="55477"; mail-complaints-to="abuse@iecc.com"
Keywords: yacc, debug
Posted-Date: 24 Feb 2016 23:54:39 EST

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.


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.