Bug 43295 - zlib: two C++ member functions could be marked const
Summary: zlib: two C++ member functions could be marked const
Status: RESOLVED WONTFIX
Alias: None
Product: gcc
Classification: Unclassified
Component: other (show other bugs)
Version: 4.5.0
: P3 trivial
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-03-08 20:39 UTC by David Binderman
Modified: 2010-03-09 10:34 UTC (History)
2 users (show)

See Also:
Host: x86_64-suse-linux
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Binderman 2010-03-08 20:39:43 UTC
I just ran the new sourceforge-based tool cppcheck over
the source code of the 4.5 snapshot 20100304 and cppcheck said

[./zlib/contrib/iostream2/zstream.h:101]: (style) The function 'izstream::fp' can be const
[./zlib/contrib/iostream2/zstream.h:234]: (style) The function 'ozstream::fp' can be const

I checked the source code and I agree with cppcheck.
Both these functions could be marked const.
Comment 1 Tom Tromey 2010-03-08 21:02:39 UTC
zlib is not maintained as part of gcc -- it is just imported into
the tree for convenience.
As such we minimize the changes we make to zlib.
A change like this one should be reported to the real zlib maintainers.
Comment 2 Jonathan Wakely 2010-03-09 10:34:36 UTC
besides which, making it const would allow:

void bork_the_stream(const izstream& i)
{
    ::gzclose(i.fp());
}

which doesn't help anyone.  cppcheck is a very simplistic pattern matcher, in this case it's wrong IMHO, that it could be const does not mean _should_ be const.