You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stdcxx.apache.org by Craig Chariton <ch...@roguewave.com> on 2006/06/02 21:28:11 UTC
Compiler Warning 552 with bitset
I am getting a compiler Warning 552 on HP-UX 11.11 with an A.03.63
compiler. Here is the code that recreates the warning:
#include <bitset>
#include <iostream>
#include <string>
#include <cstring>
int main(void)
{
const char *a = "11";
std::bitset<8> header(static_cast<std::string>(a));
for (std::string::size_type i =0; i < header.size();++i)
{
std::cout << header[i] << "\n";
}
std::cout << header.to_string<char, std::char_traits<char>,
std::allocator<char> >() + ""
<< std::endl;
return 0;
}
I am not seeing this with gcc on Linux. The code appears to run the
fine on in both cases. I was just wondering if this is a compiler issue
and, if so, is there any reason for concern?
Craig Chariton
Re: Compiler Warning 552 with bitset
Posted by Martin Sebor <se...@roguewave.com>.
Craig Chariton wrote:
> I am getting a compiler Warning 552 on HP-UX 11.11 with an A.03.63
> compiler. Here is the code that recreates the warning:
>
[...]
> I am not seeing this with gcc on Linux. The code appears to run the
> fine on in both cases. I was just wondering if this is a compiler issue
> and, if so, is there any reason for concern?
The answers are yes and no.
The HP bug number is JAGaf00255. The details of the bug report
are here: http://bugzilla.cvo.roguewave.com/show_bug.cgi?id=1536
There is no reason for concern, the compiler does the right thing
despite the warning. The warning can be suppressed either via the
compiler option +W552 or by #defining the configuration macro
_RWSTD_NO_EXT_BITSET_TO_STRING and disabling the library feature
that is giving the compiler trouble.
Note that since stdcxx implements the resolution of issue 434
and also provides, as a conforming extension, an overloaded
bitset ctor that takes a const char* argument, the program can
be simplified like this:
#include <bitset>
#include <iostream>
int main ()
{
const char *a = "11";
const std::bitset<8> header(a); // stdcxx extension
for (std::string::size_type i = 0; i < header.size (); ++i) {
std::cout << header [i] << "\n";
}
std::cout << header.to_string () << '\n'; // issue 434
}
Here's issue 434:
http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#434