Boost logo

Boost :

From: Angus Leeming (angus.leeming_at_[hidden])
Date: 2004-03-25 09:59:33


Samuel Krempp wrote:
> I'm curious, was the initialization
> truncate_(max_streamsize())
> producing any warning on your platform ?

Strangely, no. g++ is usually pretty good at diagnosing this sort of
problem.

Trying this test program on two different compilers reveals somethig
odd though:

#include <iostream>

int main()
{
        std::streamsize const a(1);
        int const b(a);
        std::streamsize c(1);
        int const d(c);
        std::cout << "sizeof(a) == " << sizeof(a)
                  << ", sizeof(b) == " << sizeof(b)
                  << ", sizeof(c) == " << sizeof(c)
                  << ", sizeof(d) == " << sizeof(d) << std::endl;
        return 0;
}

Compiling it with g++ 3.3 on an Alpha running linux:

aleem_at_thorax:aleem$ g++ -W -Wall -pedantic -o trial trial.C
aleem_at_thorax:aleem$ ./trial
sizeof(a) == 8, sizeof(b) == 4, sizeof(c) == 8, sizeof(d) == 4

No warnings :-(

Compiling it with DEC/Compaq/HP cxx 6.3 on an Alpha running tru64
unix:

aleem_at_pneumon:aleem-> cxx -std strict_ansi -w0 -o trial trial.C
cxx: Info: trial.C, line 8: conversion to integral type of smaller
size could lose data
        int const d(c);
--------------------^
cxx: Info: trial.C, line 6: variable "b" was set but never used
        int const b(a);
------------------^
cxx: Info: trial.C, line 8: variable "d" was set but never used
        int const d(c);
------------------^
aleem_at_pneumon:aleem-> ./trial
sizeof(a) == 8, sizeof(b) == 4, sizeof(c) == 8, sizeof(d) == 4

A couple of spurious warnings, but at least it also warns about the
assignment of the non-const 'c' to an int.

All very odd.

> Anyway, I fixed it in CVS (expect some delay for change to appear in
> the anonymous CVS).
>
> Thanks for reporting this bug, with so much precision !

My pleasure.
Angus


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk