Bug 59670

Summary: '%option c++' produces warnings about deprecated headers
Product: [Retired] Red Hat Linux Reporter: Enrico Scholz <rh-bugzilla>
Component: flexAssignee: Than Ngo <than>
Status: CLOSED RAWHIDE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 7.3CC: bero
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2002-03-12 13:23:08 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Patch against flex-2.5.4a-19
none
Corrected flex-2.5.4a-gcc31.patch none

Description Enrico Scholz 2002-02-11 19:18:00 UTC
Description of Problem:

flex produces C++ code which contains the deprecated

| #include <iostream.h>

The same happens when including FlexLexer.h. Both cases cause warnings (see
below) which are breaking -Werror builds.

I will attach a patch using '#include <iostream.h>' iff compiling with gcc<3;
else '#include <iostream>' will be used.

The patch for FlexLexer.h is a little bit ugly since there is to differ between
'std::istream' or 'istream'. It is done with a macro; 'using namespace std;' is
not applicably since its an include file.



Version-Release number of selected component (if applicable):

flex-2.5.4a-19


Steps to Reproduce:

1. $ cat >test.ll <<"EOF"
%option c++
%%
%%
EOF
$ flex test.ll
$ g++ -c lex.yy.cc
In file included from /usr/include/g++-v3/backward/iostream.h:31,
                from lex.yy.cc:24:
/usr/include/g++-v3/backward/backward_warning.h:32:2: warning: #warning This 
file includes at least one deprecated or antiquated header. Please consider
using one of the 32 headers found in section 17.4.1.2 of the C++ standard. 
Examples include substituting the <X> header for the <X.h> header for C++ 
includes, or <sstream> instead of the deprecated header <strstream.h>. To 
disable this warning use -Wno-deprecated.

2. $ echo '#include <FlexLexer.h>' >test.cc
$ g++ test.cc
In file included from /usr/include/g++-v3/backward/iostream.h:31,
                 from /usr/include/FlexLexer.h:47,
                 from test.cc:1:
/usr/include/g++-v3/backward/backward_warning.h:32:2: warning: #warning This
file includes at least one deprecated or antiquated header. Please consider
using one of the 32 headers found in section 17.4.1.2 of the C++ standard.
Examples include substituting the <X> header for the <X.h> header for C++
includes, or <sstream> instead of the deprecated header <strstream.h>. To
disable this warning use -Wno-deprecated.

Comment 1 Enrico Scholz 2002-02-11 19:19:17 UTC
Created attachment 45303 [details]
Patch against flex-2.5.4a-19

Comment 2 Bernhard Rosenkraenzer 2002-02-19 12:38:17 UTC
I disagree with the need for the FLEX_STD macro. We should not encourage the creation of 
non-standards compliant code, and any anywhere near current gcc can handle 
std::istream/<iostream> even if it's not enforced. 
 
I've changed the code to use the correct constructs unconditionally. (2.5.4a-20)

Comment 3 Enrico Scholz 2002-02-20 10:24:29 UTC
Since in FlexLexer.h the suggested

- #include <iostream.h>
+ #include <iostream>

was omitted, it is still in 2.5.4a-20:

| $ echo '#include <FlexLexer.h>' >test.cc
| $ g++ test.cc
| In file included from /usr/include/g++-v3/backward/iostream.h:31,
|                  from /usr/include/FlexLexer.h:47,
|                  from test.cc:1:
| /usr/include/g++-v3/backward/backward_warning.h:32:2: warning: #warning This
| file includes at least one deprecated or antiquated header. Please consider
| using one of the 32 headers found in section 17.4.1.2 of the C++ standard.
| Examples include substituting the <X> header for the <X.h> header for C++
| includes, or <sstream> instead of the deprecated header <strstream.h>. To
| disable this warning use -Wno-deprecated.



Comment 4 Bernhard Rosenkraenzer 2002-02-20 11:33:27 UTC
 Right, overlooked that one. Fixed in -21.

Comment 5 Enrico Scholz 2002-03-01 19:34:51 UTC
Still bugs in 2.5.4a-21...

In FlexLexer.h all of the 'ostream' were not replaced by 'std::ostream'; only
the 'istream' were fixed:

| $ grep ostream /usr/include/FlexLexer.h 
| #include <iostream>
|         int yylex( std::istream* new_in, ostream* new_out = 0 )
|                                          ostream* new_out = 0 ) = 0;
|         yyFlexLexer( std::istream* arg_yyin = 0, ostream* arg_yyout = 0 );
|        virtual void switch_streams( std::istream* new_in, ostream* new_out );
|        ostream* yyout; // output sink for default LexerOutput
         ~~~~~~~
         should be std::ostream; above similarly

Comment 6 Enrico Scholz 2002-03-01 19:47:06 UTC
Created attachment 47140 [details]
Corrected flex-2.5.4a-gcc31.patch

Comment 7 Than Ngo 2002-03-12 13:02:30 UTC
 It's fixed in 2.5.4a-22.

Comment 8 Enrico Scholz 2002-03-12 13:23:03 UTC
If we are speaking about the same 2.5.4a-22

| * Tue Feb 26 2002 Than Ngo <than> 2.5.4a-22
| - rebuild in new enviroment

then the bad 'ostream' is still alive...


Comment 9 Than Ngo 2002-04-02 13:06:42 UTC
oh, i have overlooked, it's definitively fixed in 2.5.4a-23 ;-)