This discussion is archived
2 Replies Latest reply: Aug 21, 2013 10:33 AM by ecdbbc38-95a9-4425-9b93-672d996667de RSS

Errors faced during migration from compiler CC: Sun C++ 5.6 to CC: Sun C++ 5.12

ecdbbc38-95a9-4425-9b93-672d996667de Newbie
Currently Being Moderated

Hi,

We have a techrefresh for one of our applications and as a part of it we have migrated from sunc compiler 5.6 to 5.12.

So we did a recompile of the code which was written against the old compiler with the new compiler

I am getting certain standard errors during the compilation.

 

The error i see is

 

Compiler.cpp", line 57: Error: Cannot use Warning_NoNewMilestones to initialize Warning_NoNewMilestones

when i enable errortags, i could see this

 

line 57: Error, badinittype: Cannot use Warning_NoNewMilestones to initialize Warning_NoNewMilestones

 

The line of code causing this error is

THROWERR Warning_NoNewMilestones();  which is equivelent to throw Warning_NoNewMilestones();

These are the class declarations

class Warning : public Error
{
public:
Warning(void)
: Error(-8)
{}
};

 

class Warning_NoNewMilestones : public Warning
{
public:
Warning_NoNewMilestones(void)
{ (*this) << "No new milestones were generated since last run."
<< ends;
}
};

 

The error gets cleard if i make the following change to the code
THROWERR new Warning_NoNewMilestones();   (just added the key word new)

 

I need to make this change in almost 100 places to clear the errors.

IS there any compiler option that will help in fixing this issue rather than changing the code at lot of places.

The compiler option used currently is

 

/opt/solarisstudio12.3/bin/CC -c  -g -dn -errtags=yes –DsunOS  Source.cpp include files –o object file

Source.cpp -is a sample  source file

 

Apart from the above error i dod see some standard errors as a part of this compiler migration.

They are

badarglval2

badbinaryop

badinittype

 

 

Will you be able to provide the correct compiler option to resolve this error or should i need to migrate to

any newer version of the compiler. My only doubt is the code works well in the old compiler. I expect it to

work fine even in the new compiler.

 

Any suggestions or help would be greatly appreciated.

  • 1. Re: Errors faced during migration from compiler CC: Sun C++ 5.6 to CC: Sun C++ 5.12
    Steve_Clamage Pro
    Currently Being Moderated

    I can't tell what  the compiler is complaining about. I tried a version of your code sample:

    struct Error { Error(int); };

    struct Warning : public Error {

        Warning(void) : Error(-8) {}

    };

    struct Warning_NoNewMilestones : public Warning {

        Warning_NoNewMilestones(void) { }

    };

    int main()

    {

        throw  Warning_NoNewMilestones();

    }

    It compiled without complaint using C++ 5.12 (Studio 12.3).


    There are always two possibilities: The code is OK and you hit a compiler bug, or the code was always invalid but the earlier compiler did not catch the error. Since you seem to have a variety of error messages, the most likely scenario is that the new compiler is catching more errors in your code.


    In general, there is no option to have the compiler accept invalid code. In rare cases, where the error is harmless, or when other compilers typically accept the invalid code, we have an option to allow the code. Please review the list of compiler options in Appendix A of the C++ Users Guide.

    Oracle Solaris Studio 12.3 Information Library

     

    If the reason for an error message is not obvious, you can post a (preferably small) example that can be compiled to show the error message. Someone in the forum can then probably explain the error, or verify that you hit a compiler bug.

     

    Here is an example of the badbinaryop error message:

    % cat z.cc

    struct S { };

    int main()

    {

        S s;

        int j = s + 3;

    }

    % CC z.cc

    "z.cc", line 5: Error: The operation "S + int" is illegal.

    1 Error(s) detected.

     

    I hope the reason for the error is obvious in this case.

  • 2. Re: Errors faced during migration from compiler CC: Sun C++ 5.6 to CC: Sun C++ 5.12
    ecdbbc38-95a9-4425-9b93-672d996667de Newbie
    Currently Being Moderated

    Thx Steve, tomorrow i will post you the sample code through which i reproduced the error.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points