Bug 166736

Summary: std::showbase fails for hex value 0
Product: [Fedora] Fedora Reporter: D. Stimits <stimits>
Component: gcc4Assignee: Jakub Jelinek <jakub>
Severity: medium Docs Contact:
Priority: medium    
Version: 4   
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2005-08-25 02:43:01 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Description D. Stimits 2005-08-25 02:19:26 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050511

Description of problem:
std::showbase combined with std::hex in <iostream> fails to show the base if the value is 0. The following program should produce "0x0" as the output in all lines which start with:
std::cout << std::hex << std::showbase...

Instead this program produces output "0", skipping the "0x" base.

// main.cxx
#include <iostream>

int main()
   unsigned int var = 0;
   std::cout << var << "\n";

   // This is a failure line, it outputs "0" instead of "0x0".
   std::cout << std::hex << std::showbase << var << "\n";

   var = 1;
   std::cout << var << "\n";
   std::cout << std::hex << std::showbase << var << "\n";

   return 0;

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

How reproducible:

Steps to Reproduce:
1. Use std::hex and std::showbase in a std::cout, then feed 0 to the stream.

Actual Results:  Outputs "0".

Expected Results:  Outputs "0x0".

Additional info:


Comment 1 D. Stimits 2005-08-25 02:43:01 UTC
Looks like bugzilla figured out how to double submit this one for me. This is a
duplicate of 166735 which I did not submit.

*** This bug has been marked as a duplicate of 166735 ***