[comp.lang.c++] [ diff g++ C++ ] && miracle

jk@cs.man.ac.uk (John Kewley ICL) (09/07/90)

After following the recent discussions on const I tried the following:

#include <stdio.h>

char* sub(char* x)
{
        return x;
};

const char* const sub(const char* const x)
{
        return "HELLO";
};

int main()
{
        const char* const hello= "Hello";
        char* world= "World";

        printf("%s %s%s", sub(hello), sub(world), sub("\n"));
        return(0);
};

g++ was happy, Sun2.0 C++ was not. Is my code incorrect?

--
        J.K.
 
John M. Kewley, ICL, Wenlock Way, West Gorton, Manchester. M12 5DR
Tel:   (+44) 61 223 1301 X2138  Email: jk@r6.cs.man.ac.uk / jk@nw.stl.stc.co.uk