Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#188 operator>>(void*&) doesn't work

5.1
open-out-of-date
3
2009-04-07
2008-10-07
Maxim Yanchenko
No

Hi, it looks like operator>>(void*&) doesn't work (i.e. the default num_get::do_get(...,void*&) doesn't work).

See this simple test:

#include <iostream>
#include <sstream>
#include <stdio.h>

int main()
{
int q=5;
void *x1=&q, *x2=0, *x3=0;
std::cerr << "x1: " << x1 << std::endl;
std::cerr << "x2: " << x2 << std::endl;
std::stringstream ss;
ss << x1;
ss >> x2;
std::cerr << "x2: " << x2 << std::endl;

char sss[256] = "";
fprintf(stderr, "x1 = %p\n", x1);
fprintf(stderr, "x3 = %p\n", x3);
sprintf(sss, "%p", x1);
sscanf(sss, "%p", &x3);
fprintf(stderr, "x3 = %p\n", x3);
}

compiling with gcc 3.4.6.

output with gcc standard library:
x1: 0x7fbffff11c
x2: 0
x2: 0x7fbffff11c
x1 = 0x7fbffff11c
x3 = (nil)
x3 = 0x7fbffff11c

output with STLPort 5.1.5:
x1: 0x0000007fbffff11c
x2: 000000000000000000
x2: 000000000000000000
x1 = 0x7fbffff11c
x3 = (nil)
x3 = 0x7fbffff11c

same locale settings.

As you can see, STLPort fails to load a pointer.

According to the Standard, it should work both ways as printf/scanf's %p, which is two-way working.

Discussion

  • test example

     
    Attachments
  • Added a test for null pointer and uploaded the amended version of the test file.
    Please see the results (GCC 3.4.6):

    Built-in STL:
    STL : x1 (orig): 0x7fbffff4cc
    STL : x2 (init): 0
    STL : x2 (x1 ?): 0x7fbffff4cc <<< good
    STL : x2 (null): 0x7fbffff4cc <<< bad
    stdio: x1 (orig) = 0x7fbffff4cc
    stdio: x2 (init) = (nil)
    stdio: x2 (x1 ?) = 0x7fbffff4cc << good
    stdio: x2 (null) = (nil) << good

    STLPort 5.1.5:
    STL : x1 (orig): 0x0000007fbffff4cc
    STL : x2 (init): 000000000000000000
    STL : x2 (x1 ?): 000000000000000000 <<< bad
    STL : x2 (null): 0x0000007fbffff4cc <<< bad
    stdio: x1 (orig) = 0x7fbffff4cc
    stdio: x2 (init) = (nil)
    stdio: x2 (x1 ?) = 0x7fbffff4cc << good
    stdio: x2 (null) = (nil) << good

    As you can see, builtin STL successfully loads non-null pointer, but fails to load null pointer.
    STLPort fails to load both.

     
    • priority: 5 --> 3
     
  • See STLport 5.2 or suggest patch.

     
    • assigned_to: nobody --> complement
    • status: open --> closed-out-of-date
     
  • 5.2 and mainstream has unit tests for this issue, and pass. Changes to 5.1 may be considered only if you suggest patch (+ regression test). No responce: issue closed.

     
    • status: closed-out-of-date --> open-out-of-date
     
  • 5.2 is OK for me. Thanks, Petr!