c++ - flex cout string crash -


when try print string(cout) in flex program, program crashs. .l file looks this:

%{     #include <iostream>     #include <string>      using namespace std; %}  %option noyywrap  %% .   {string str = "hi"; cout << str;} %%  int main(){     yylex();      return 0; } 

i compile generated files g++. flex version 2.5.35.

when write cout << "hi"; program not crash.

what doing wrong?

it seems work flex version 2.5.39.

you can preprocess generated file g++ -e , @ output see if translation of

{string str = "hi"; cout << str;} 

has not changed.


Comments