This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Promotion through assignment?


Is this non-promotion an issue with gcc (2000612) or an aggressive
promotion by MSVC (which compiles it fine)? A private Cc: is
appreciated.

#include <string>

class R
{
public:
    R( void ) {
    name[0] = '\0';
    value[0] = '\0';
    }
    R( const char* n, const char* v ) {
    strncpy( name, n, 64 );
    strncpy( value, v, 128 );
    }

    operator std::string() const;
private:
    char name[64];
    char value[128];
};

R::operator std::string() const {
    std::string s( name );
    s += '/';
    s += value;
    return s;
}

class I
{
public:
    I( const std::string& s );

private:
    char id[256];
};

I::I( const std::string& s )
{
    strncpy( id, s.c_str( ), 256 );
}

int main( int argc, char* argv[] )
{
    R r( "name", "value" );
#if 1
    I i = r;
#else
    I i( r );
#endif

    return 0;
}

m.

-- 
Programmer             "Ha ha." "Ha ha." "What are you laughing at?"
Loki Software                      "Just the horror of being alive."
http://lokigames.com/~briareos/                   - Tony Millionaire

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]