Go to main content
What's New in the Oracle® Developer Studio 12.6 Release

Exit Print View

Updated: July 2017
 
 

C++ Compiler Changes

This section includes the changes that are described in New and Changed Features Common to the Compilers.

The new features in this release specific to the C++ compiler are as follows:

  • New section attribute – The C++ compiler now provides a new section attribute that specifies a variable or a function present in a particular section.

  • Inlining Behavior Change for -xO3 – Supports automatic inlining of functions whose body is smaller than the calling overhead. In addition, the -xO3 and -xO4 result in the minimum code size when used with the –xspace option.

  • Change in –xlibmopt Option – The –xlibmopt option has been enhanced with the –%none, –archive, and –shared sub-options.

  • libCrunG3 Linked Statically on LinuxlibCrunG3 is a runtime support library needed by C++ programs that are compiled with any of the options, -compat=g, -std=c++03, -std=c++11, or -std=c++14.

    On Oracle Solaris, libCrunG3 is linked dynamically by default, when needed. It is part of the Oracle Solaris Operating System, and hence it can always be found by user programs. On Linux, you would need to supply libCrunG3.so.1 with your program if you linked the library dynamically. To avoid this problem, libCrunG3, when needed, is linked statically by default on Linux.

  • Improved Error Reporting in Function Overload Resolution – The previous compilers of Oracle Developer Studio and Oracle Solaris Studio did not provide detailed messages in reporting ambiguous or unresolvable calls to overloaded functions. In Oracle Developer Studio 12.6, the error reporting has been improved. The following examples illustrate the improved error reporting feature.

    Example 1:
    
    % cat ex1.cc
    void f(int n, int* ptr);
    void f(int, int, int);
    void f(int);
    void foo()
    {
        f(1, 2);
    }

    The previous compilers reported a message like:

    % CC -c ex1.cc
    "ex1.cc", line 7: Error: Could not find a match for f(int, int) needed in
    foo().
    1 Error(s) detected.
    

    The Oracle Developer Studio 12.6 C++ compiler provides more information about why no match could be found.

    % CC -c ex1.cc
    "ex1.cc", line 7: Error: Could not find a match for f(int, int) needed in
    foo().
    "ex1.cc", line 1: Note: Candidate 'f(int, int*)' is not viable: argument
    'ptr' can't be converted from 'int' to 'int*'.
    "ex1.cc", line 3: Note: Candidate 'f(int)' is not viable: too many arguments.
    "ex1.cc", line 2: Note: Candidate 'f(int, int, int)' is not viable: too few
    arguments.
    Example 2:
    
    % cat ex2.cc
    struct A;
    struct B {
        B(const A&);
    };
    struct D1 : B {};
    struct D2 : B {};
    struct A {
        A();
        operator  D1() const;
        operator  D2&() volatile ;
    };
    void foo(A& ra)
    {
        A va;
        B vb  = ra;
    }

    The previous compilers reported a message like:

    % CC -c ex2.cc
    "ex2.cc", line 19: Error: Overloading ambiguity between "A::operator D1()
    const" and "B::B(const A&)".
    "ex2.cc", line 19: Error: Cannot use A to initialize B.
    2 Error(s) detected.

    The Oracle Developer Studio 12.6 C++ compiler provides more information about the ambiguity.

    % CC -c ex2.cc
    "ex2.cc", line 19: Error: Type conversion 'A' -> 'B' is ambiguous.
    "ex2.cc", line 12: Note: Viable candidate 'A::operator D1() const'.
    "ex2.cc", line 4: Note: Viable candidate 'B::B(const A&)'.
    "ex2.cc", line 13: Note: Viable candidate 'A::operator D2&() volatile'.
    "ex2.cc", line 19: Error: Cannot use A to initialize B.
    
    You can disable generation of the Notes by using the CC option
        -features=no%note

For more information, see the Oracle Developer Studio 12.6: C++ User’s Guide and the CC(1) man page.