Studio 10 compiler bug with example

The following example produces a crash on Solaris Intel with Sun Studio 10, but works with Workshop 6 update 2.
This example describes the simple case of using Xerces-c C++'s DefaultHandler class from a shared library.
Running "main" will crash using Sun Studio 10 on Solaris 10 x86 but exits normally on Solaris any Sparc.
Execute the following commands to build the example:
CC -mt -G -g -KPIC -c t1.cpp -o t1.o -g -fns -features=rtti -lpthread
CC -mt -G -g -o libt1.so t1.o -z defs -lCrun -lc
CC -mt -G -g -KPIC -c t2.cpp -o t2.o -g -fns -features=rtti -lpthread
CC -mt -G -g -o libt2.so t2.o -z defs -lCrun -lc libt1.so
CC -mt -g -o main main.cpp -features=rtti -Bdynamic libt2.so
Contents of main.cpp:
#include "t2.h"
#include "unistd.h"
int main(void)
CT2Start* t2start = new CT2Start();
t2start->Start();
delete t2start;
return 0;
Contents of t1.h:
class CT1A
public:
virtual void T1(void) = 0;
class CT1B
public:
class CT1 :
public CT1B,
public CT1A
public:
virtual void T1(void);
inline void CT1::T1(void)
class CT1Start
public:
void Start(CT1A* t1a);
Contents of t1.cpp:
#include "t1.h"
class CDoSomething
public:
void DoSomething(void)
void CT1Start::Start(CT1A* t1a)
CDoSomething* doSomething = new CDoSomething();
t1a->T1();
doSomething->DoSomething();
delete doSomething;
Contents of t2.h:
#include "t1.h"
class CT2 : public CT1
public:
virtual void T1(void);
class CT2Start
public:
void Start(void);
Contents of t2.cpp:
#include "t2.h"
void CT2::T1(void)
void CT2Start::Start(void)
CT2* t2 = new CT2();
CT1Start* t1start = new CT1Start();
t1start->Start(t2);
delete t1start;
delete t2;
}

Your build script has some problems. You are using the -G option when you intend to compile to a .o, but -G is for creating a shared library. There are problems with library dependencies . You build libt2.so with a dependency on libt1.so, but libt1 is does not satisfy any references in libt2, so the dependency has no effect. You need to list libt1 when building the executable. (Maybe in the real program libt1 is needed by libt2.)
You don't need to use LD_LIBRARY_PATH at all. You should instead build a run-path into the executable, using the -R option. For reasons why you should never set LD_LIBRARY_PATH, see this blog entry:
http://blogs.sun.com/roller/page/rie?anchor=tt_ld_library_path_tt
Here is a corrected build script:
CC -mt -c -g -KPIC t1.cpp
CC -mt -G -g -o libt1.so t1.o -z defs -lCrun -lpthread -lc
CC -mt -c -g -KPIC t2.cpp
CC -mt -G -g -o libt2.so t2.o -z defs libt1.so -lCrun -lpthread -lc
CC -mt -g -o main main.cpp libt1.so libt2.so -lpthread -R.
I have omitted the -features=rtti, since it is the default, and has no effect. I also omitted the -fns. You can put it back if you don't want standard floating-point results.
I verified the problem using the original release of Studio 10. Using the current patched version, the code runs as originally written.
You can get the current patches here:
http://developers.sun.com/prodtech/cc/downloads/patches/index.html

Similar Messages

  • Compiler bug with generics and private inner classes

    There appears to be a bug in the sun java compiler. This problem was reported against eclipse and the developers their concluded that it must be a problem with javac.
    Idea also seems to compile the example below. I couldn't find a bug report in the sun bug database. Can somebody tell me if this is a bug in javac and if there is a bug report for it.
    https://bugs.eclipse.org/bugs/show_bug.cgi?id=185422
    public class Foo <T>{
    private T myT;
    public T getT() {
    return myT;
    public void setT(T aT) {
    myT = aT;
    public class Bar extends Foo<Bar.Baz> {
    public static void main(String[] args) {
    Bar myBar = new Bar();
    myBar.setT(new Baz());
    System.out.println(myBar.getT().toString());
    private static class Baz {
    @Override
    public String toString() {
    return "Baz";
    Eclipse compiles and runs the code even though the Baz inner class is private.
    javac reports:
    Bar.java:1: Bar.Baz has private access in Bar
    public class Bar extends Foo<Bar.Baz>
    ^
    1 error

    As I said in my original post its not just eclipse that thinks the code snippet is compilable. IntelliJ Idea also parses it without complaining. I haven't looked at the java language spec but intuitively I see no reason why the code should not compile. I don't think eclipse submitting bug reports to sun has anything to do with courage. I would guess they just couldn't be bothered.

  • SDK 3.0: Compiler bug with std::deque?

    When I call std::deque::assign(), I get all kinds of compile-time errors, including internal compiler errors.
    Note, however, that this happens only when I compile for the 3.0 device. It does not happen when I compile for the 3.0 simulator, 2.x device or 2.x simulator. In all those other modes it compiles and works just fine. Only when compiling for the 3.0 device, the compiler errors happen.
    I'm pretty certain this is a bug in the SDK. Has anyone else noticed this?

    Assign is a particularly tricky one. There are two assign methods. One takes two iterators and the other takes a size and value:
    template<class InputIterator>
    void assign(InputIterator first, InputIterator last);
    void assign(size_type n, const T & t);
    For whatever reason, the compiler for the 3.0 device is saying "int" and "int *" are the same type. It is instantiation the version with the iterators instead of the second one. This is a typical error you might see on a platform with weak C++ support. I used to have to deal with things like this all the time in the early days of MacOS X.
    Unfortunately, the only workaround is to do something else. The following should work:
    #include <algorithm>
    std::deque<int> values;
    std::filln(std::backinserter(values), 10, 1);

  • BUG: Oracle Java Compiler bug with anonymous inner classes in constructor

    The following code compiles and runs just fine using 1.4.2_07, 1.5.0_07 and 1.6.0_beta2 when compiling and running from the command-line.
    It does not run when compiling from JDeveloper 10.1.3.36.73 (which uses the ojc.jar).
    When compiled from JDeveloper, the JRE (both the embedded one or the external 1.5.0_07 one) reports the following error:
    java.lang.VerifyError: (class: com/ids/arithmeticexpr/Scanner, method: <init> signature: (Ljava/io/Reader;)V) Expecting to find object/array on
    stack
    Here's the code:
    /** lexical analyzer for arithmetic expressions.
    Fixes the lookahead problem for TT_EOL.
    public class Scanner extends StreamTokenizer
    /** kludge: pushes an anonymous Reader which inserts
    a space after each newline.
    public Scanner( Reader r )
    super( new FilterReader( new BufferedReader( r ) )
    protected boolean addSpace; // kludge to add space after \n
    public int read() throws IOException
    int ch = addSpace ? ' ' : in.read();
    addSpace = ch == '\n';
    return ch;
    public static void main( String[] args )
    Scanner scanner = new Scanner( new StringReader("1+2") ); // !!!
    Removing the (implicit) reference to 'this' in the call to super() by passing an instance of a static inner class 'Kludge' instead of the anonymous subclass of FilterReader fixes the error. The code will then run even when compiled with ojc. There seems to be a bug in ojc concerning references to the partially constructed object (a bug which which is not present in the reference compilers.)
    -- Sebastian

    Thanks Sebastian, I filed a bug for OJC, and I'll look at the Javac bug. Either way, OJC should either give an error or create correct code.
    Keimpe Bronkhorst
    JDev Team

  • Workshop 6 Bug with STLport hash_map operator []

    Using hash_map<string, string>:operator[] in a debug build crashes; in release, it doesn't. This must be a compiler bug, yes? Here's how to reproduce it.
    <PRE>
    [valhalla:~/test] $ cat t.c
    #include <string>
    #include <hash_map>
    using namespace std;
    main()
    hash_map<string, string> m;
    m["stl"] = "port";
    string s = m["stl"];
    [valhalla:~/test] $ rm -rf SunWS_cache/
    [valhalla:~/test] $ CC -I/apps/stlport-4.5.3/stlport -L/apps/stlport-4.5.3/lib -R/apps/stlport-4.5.3/lib -lstlport_sunpro t.c
    [valhalla:~/test] $ a.out
    [valhalla:~/test] $ rm -rf SunWS_cache/
    [valhalla:~/test] $ CC -g -I/apps/stlport-4.5.3/stlport -L/apps/stlport-4.5.3/lib -R/apps/stlport-4.5.3/lib -lstlport_sunpro t.c
    [valhalla:~/test] $ a.out
    Bus Error (core dumped)
    [valhalla:~/test] $ dbx -q a.out core
    core file header read successfully
    program terminated by signal BUS (invalid address alignment)
    Current function is STL::_stl_delete
    99 inline void STLPCALL __stl_delete(void* __p) { ::operator delete(__p); }
    (dbx) where
    [1] freeunlocked(0xffbee657, 0xff23a000, 0xffbee657, 0xff23a000, 0x237e8, 0xff1c291c), at 0xff1c2974
    [2] free(0xffbee657, 0xffbee5d4, 0xffbee658, 0xffbee5e2, 0xffbee5e1, 0xff19bb88), at 0xff1c2924
    [3] operator delete(0xffbee657, 0xffbee658, 0xffbee657, 0xff37e540, 0x13bb0, 0x1ee00), at 0xff3636f8
    =>[4] STL::_stl_delete(__p = 0xffbee657), line 99 in "new"
    [5] STL::_node_alloc<true,0>::deallocate(__p = 0xffbee657, __n = 4347225U), line 253 in "_alloc.h"
    [6] STL::allocator<char>::deallocate(this = 0xffbee5b0, _p = 0xffbee657 "", __n = 4347225U), line 360 in "_alloc.h"
    [7] STL::STLP_alloc_proxy<char*,char,_STL::allocator<char> >::deallocate(this = 0xffbee5b0, __p = 0xffbee657 "", __n = 4347225U), line 506 in "_alloc.h"
    [8] STL::String_base<char,_STL::allocator<char> >::_M_deallocate_block(this = 0xffbee5a8), line 124 in "_string.h"
    [9] STL::String_base<char,_STL::allocator<char> >::~_String_base(this = 0xffbee5a8), line 135 in "_string.h"
    [10] STL::basicstring<char,_STL::char_traits<char>,_STL::allocator<char> >::~basic_string(this = 0xffbee5a8), line 302 in "_string.h"
    [11] STL::hashmap<_STL::basic_string<char,_STL::char_traits<char>,_STL::allocator<char> >,_STL::basic_string<char,_STL::char_traits<char>,_STL::allocator<char> >,_STL::hash<_STL::basic_string<char,_STL::char_traits<char>,_STL::allocator<char> > >,_STL::equal_to<_STL::basic_string<char,_STL::char_traits<char>,_STL::allocator<char> > >,_STL::allocator<_STL::pair<const STL::basicstring<char,_STL::char_traits<char>,_STL::allocator<char> >,_STL::basic_string<char,_STL::char_traits<char>,_STL::allocator<char> > > > >::operator[](this = 0xffbee680, __key = CLASS), line 186 in "_hash_map.h"
    [12] main(), line 8 in "t.c"
    (dbx) exit
    [valhalla:~/test] $ exit
    exit
    [valhalla:~/test] $ which CC
    /apps/SUNWspro64/bin/CC
    [valhalla:~/test] $ CC -V
    CC: Sun WorkShop 6 update 1 C++ 5.2 Patch 109508-09 2002/07/08
    [valhalla:~/test] $ uname -a
    SunOS valhalla 5.8 Generic_108528-15 sun4u sparc SUNW,Sun-Blade-100
    </PRE>
    STLport places all of its classes in its own _STL namespace, so there is no concern for name collision with std types that come with the Sun compiler. 
    Any ideas?
    Regards,
    Jason

    I found out this is compiler bug with Forte 6 that ocurrs when inlining is enabled and temporaries are used in conditional expressions with the ?: operator, e.g.,
    [valhalla:~/test] $ cat tt.c
    #include <iostream>
    #include <stdlib.h>
    using namespace std;
    struct X {
    X() { cout << "X ctor" << endl; }
    ~X() { cout << "X dtor" << endl; }
    int foo() { return 1; }
    struct Y {
    Y() { cout << "Y ctor" << endl; }
    ~Y() { cout << "Y dtor" << endl; }
    int foo() { return 1; }
    inline int foo(int i)
    return i ?
    X().foo() :
    Y().foo() ;
    main(int, char **argv)
    return foo(atoi(argv[1]));
    [valhalla:~/test] $ rm -rf SunWS_cache/
    [valhalla:~/test] $ CC -g tt.c
    [valhalla:~/test] $ a.out 1
    X ctor
    X dtor
    [valhalla:~/test] $ rm -rf SunWS_cache/
    [valhalla:~/test] $ CC tt.c
    [valhalla:~/test] $ a.out 1
    X ctor
    Y dtor
    X dtor
    [valhalla:~/test] $ g++ tt.c
    [valhalla:~/test] $ a.out 1
    X ctor
    X dtor

  • Ridiculous bug in oracle jdeveloper compiler ojc with jdk1.4

    With simple class:
    public class Test
    public Test()
    public String toString()
    return null;
    public static void main(String[] args) throws Exception
    Test test = new Test();
    System.out.println("ooo" + test);
    After compile it with ojc (ojc Test.java) and run it with jdk 1.4.1_01 (java Test), it throws
    java.lang.NullPointerException
    at java.lang.String.concat(String.java:1541)
    But it works ok if compile it with standard java compiler(javac).

    Hi,
    Thanks for reporting this. It's a bug. I've logged it as 2809860, and you can track this on metalink.oracle.com.
    Brian
    JDev Team

  • SS9 CC5.6 compiler bug - algorithm count confused with struct member

    Found some code that fails to compile in CC 5.6
    CC: Sun C++ 5.6 2004/07/15
    #include <algorithm>
    using namespace std;
    struct A {
      int count;   
    struct B
      struct A *a;
    int main(int argc, char **argv)
      struct B *b = 0;
      // This line fails to build, any other operator is ok
      if ( b->a->count < 50 )
      return (1);
    }Fails with error :
    "c56_algorithm_bug.cpp", line 21: Error: Unexpected ")" -- Check for matching parenthesis.
    "c56_algorithm_bug.cpp", line 22: Error: "," expected instead of "{".
    "c56_algorithm_bug.cpp", line 22: Error: Illegal value for template parameter.
    "c56_algorithm_bug.cpp", line 22: Error: ")" expected instead of "{".
    4 Error(s) detected.The compiler is getting confused with the use of the count struct member vs the count algorithm. Changing the < to a > fixes the problem.
    Using CC5.3 works fine as well as all other compilers we use (gcc 3.4, mipspro 7.4, VC 7.1)
    Anyone seen this ?
    - mark

    This bug has been fixed in the C++ 5.6 compiler. I'm not sure if the fix is in the first patch which is about to be released. If not, the fix definitely will be in the next patch.
    The workaround is not to use
    using namespace std;That using-declaration is a pretty big hammer, and often results in conflicts with user code, compiler bugs aside.

  • Is it possible to run sun studio 12 ide with sun studio 8 compiler?

    Hi, i am in the process of evaluating sun studio 12. Our company cannot move to sun studio 12 compiler collection right now as it is a huge code base and it will take us few months even before we start using sun studio 12 compiler in our development environment. Is it possible to use sun studio 12 ide with sun studio 8 compiler collection(CC, dbx etc)? Your feedback is appreciated. thank you.

    There are two parts to the answer.
    1) whether you can
    To choose a compiler set follow Tools->Options->C/C++
    and in the BuildTools tab you'll see how it picks up
    compilers from your PATH.
    This dialog doesn't govern choice of dbx, which will always
    come from the installation. However you can alter which dbx
    is used by presetting the environment variable SPRO_DBX_PATH
    to teh full pathname of a dbx of your choice.
    2) whether you should
    The IDE should work reasonably well with older compilers. They
    are not that tightly bound.
    The IDE will not work well enough with an older dbx, especially as
    old as studio 8. However, while not officially supported or tested
    the SS12 dbx should be reasonably bwd compatible with code
    generated from older compilers.
    So my recommendation is: don't use SPRO_DBX_PATH and
    give the old compilers a try.

  • Problem with examples in dbxml 2.4.13

    I downloaded a time ago dbxml 2.4.13 for windows (msi file) I tried to compile the helloworld example. That went fine, but when I run it, I it get always a memory exception problem.
    Unhandled exception at 0x7c812aeb in dbxmltest.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0012f188..
    It does not matter if I run in debug or release configuration, I alway get this error at the very first call to the lib at line with
    XmlManager mgr;
    Has anyone a clue what I did wrong here? Maybe I build it wrong ?
    My compile flags are :
    /Od /I "C:\Program Files\Oracle\Berkeley DB XML 2.4.13\include" /D "_MBCS" /Gm /EHsc /RTC1 /MDd /Fo"Debug\\" /Fd"Debug\vc90.pdb" /W3 /nologo /c /ZI /TP /errorReport:prompt
    My linking flags are:
    /OUT:"X:\dbxmltest\dbxmltest\Debug\dbxmltest.exe" /NOLOGO /LIBPATH:"C:\Program Files\Oracle\Berkeley DB XML 2.4.13\lib" /MANIFEST /MANIFESTFILE:"Debug\dbxmltest.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"x:\dbxmltest\dbxmltest\Debug\dbxmltest.pdb" /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:PROMPT libdbxml24.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
    The output window is :
    'dbxmltest.exe': Loaded 'X:\dbxmltest\dbxmltest\Debug\dbxmltest.exe', Symbols loaded.
    'dbxmltest.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll'
    'dbxmltest.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll'
    'dbxmltest.exe': Loaded 'C:\Program Files\Oracle\Berkeley DB XML 2.4.13\bin\libdbxml24.dll', Symbols loaded.
    'dbxmltest.exe': Loaded 'C:\Program Files\Oracle\Berkeley DB XML 2.4.13\bin\libdb46.dll', Symbols loaded.
    'dbxmltest.exe': Loaded 'C:\WINDOWS\system32\ws2_32.dll'
    'dbxmltest.exe': Loaded 'C:\WINDOWS\system32\advapi32.dll'
    'dbxmltest.exe': Loaded 'C:\WINDOWS\system32\rpcrt4.dll'
    'dbxmltest.exe': Loaded 'C:\WINDOWS\system32\secur32.dll'
    'dbxmltest.exe': Loaded 'C:\WINDOWS\system32\msvcrt.dll'
    'dbxmltest.exe': Loaded 'C:\WINDOWS\system32\ws2help.dll'
    'dbxmltest.exe': Loaded 'C:\WINDOWS\system32\msvcr71.dll'
    'dbxmltest.exe': Loaded 'C:\WINDOWS\system32\msvcp71.dll'
    'dbxmltest.exe': Loaded 'C:\Program Files\Oracle\Berkeley DB XML 2.4.13\bin\xqilla21.dll', Symbols loaded.
    'dbxmltest.exe': Loaded 'C:\Program Files\Oracle\Berkeley DB XML 2.4.13\bin\xerces-c_2_8.dll'
    'dbxmltest.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC90.DebugCRT_1fc8b3b9a1e18e3b_9.0.30729.1_x-ww_f863c71f\msvcp90d.dll'
    'dbxmltest.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC90.DebugCRT_1fc8b3b9a1e18e3b_9.0.30729.1_x-ww_f863c71f\msvcr90d.dll'
    'dbxmltest.exe': Loaded 'C:\Norman\Nvc\Bin\Niphk.dll', Binary was not built with debug information.
    'dbxmltest.exe': Loaded 'C:\WINDOWS\system32\user32.dll'
    'dbxmltest.exe': Loaded 'C:\WINDOWS\system32\gdi32.dll'
    'dbxmltest.exe': Loaded 'C:\WINDOWS\system32\oleaut32.dll'
    'dbxmltest.exe': Loaded 'C:\WINDOWS\system32\ole32.dll'
    'dbxmltest.exe': Loaded 'C:\WINDOWS\system32\imm32.dll'
    'dbxmltest.exe': Loaded 'C:\WINDOWS\system32\ntmarta.dll'
    'dbxmltest.exe': Loaded 'C:\WINDOWS\system32\samlib.dll'
    'dbxmltest.exe': Loaded 'C:\WINDOWS\system32\wldap32.dll'
    'dbxmltest.exe': Loaded 'C:\WINDOWS\system32\winsta.dll'
    'dbxmltest.exe': Loaded 'C:\WINDOWS\system32\netapi32.dll'
    HEAP[dbxmltest.exe]: Invalid Address specified to RtlFreeHeap( 003E0000, 100D5740 )
    Windows has triggered a breakpoint in dbxmltest.exe.
    This may be due to a corruption of the heap, which indicates a bug in dbxmltest.exe or any of the DLLs it has loaded.
    This may also be due to the user pressing F12 while dbxmltest.exe has focus.
    The output window may have more diagnostic information.
    I hope anyone can help me, thanks

    Thanks for the quick reply.
    I am already in the building process. But I have another problem now. I took the latest source files from the site (2.4.16) and followed the instructions at http://www.oracle.com/technology/documentation/berkeley-db/xml/ref_xml/xml_win/intro.html
    I follow the instructions in section : Building with Microsoft Visual Studio 2008 and Visual C++ 2008 Express Edition because I use the express edition.
    But when compiling XercesLib There is a strange error which I cannot find a solution for.
    1>Base64.cpp
    1>Generating Code...
    1>Compiling resources...
    1>Microsoft (R) Windows (R) Resource Compiler Version 6.1.6723.1
    1>Copyright (C) Microsoft Corporation. All rights reserved.
    1>..\..\..\..\..\src\xercesc\util\Platforms\Win32\Version.rc(10) : fatal error RC1015: cannot open include file 'winres.h'.
    1>Build log was saved at "file://x:\dbxml-2.4.16\xerces-c-src\Build\Win32\VC8\Debug\obj\BuildLog.htm"
    1>XercesLib - 1 error(s), 9 warning(s)
    ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
    Is it not possible to compile the latest version with Visual C++ 2008 Express Edition ?

  • Optimization bug with C++ inlining

    Hi,
    While evaluating Sun Studio 11 I have identified an optimization bug with C++ inlining.
    The bug can easily be reproduced with the small program below. The program produces
    wrong results with -xO2, because an inline access function always returns the value 0.0
    instead of the value given on the commandline:
    djerba{ru}16 : CC -o polybug  polybug.cc
    djerba{ru}17 : ./polybug 1.0
    coeff(0): 1.000000
    djerba{ru}18 : CC -o polybug -xO2 polybug.cc
    djerba{ru}19 : ./polybug 1.0
    coeff(0): 0.000000            <<<<<<<<<< wrong, should be 1.000000This occurs only with optimization level O2; levels below or above O2 don't
    exhibit the bug.
    Compiler version is
    Sun C++ 5.8 Patch 121017-01 2005/12/11
    on Solaris 8 / Sparc.
    I include a preliminary analysis at the end.
    Best Regards
    Dieter R.
    -------------------- polybug.cc -------------------------
    // note: this may look strange, but this is a heavily stripped down
    // version of actual working application code...
    #include <stdio.h>
    #include <stdlib.h>
    class Poly {
      public:
        // constructor initializes number of valid coefficients to zero:
        Poly() { numvalid = 0; };
        ~Poly() {};
        // returns coefficient with index j, if valid. Otherwise returns 0.0:
        double coeff(int j) {
         if (j < numvalid) {
             return coefficients[j];
         } else {
             return 0.0;
       // copies contents of this Object to other Poly:
        void getPoly(Poly& q) { q = *this; };
        // data members:
        // valid coefficients: 0 ... (numvalid - 1)
        double coefficients[6];
        int numvalid;
    void troublefunc(Poly* pC) {
        // copies Poly-Object to local Poly, extracts coefficient
        // with index 0 and prints it. Should be the value given
        // on commandline.
        // Poly constructor, getPoly and coeff are all inline!
        if (pC) {
         Poly pol;                      
         pC->getPoly(pol);
         printf("coeff(0): %f\n",pol.coeff(0));
    int main(int argc,char* argv[]) {
        double d = atof(argv[1]);
        // creates Poly object and fills coefficient with index
        // 0 with the value given on commandline
        Poly* pC = new Poly;
        pC->coefficients[0] = d;
        pC->numvalid = 1;
        troublefunc(pC);   
        return 0;
    The disassembly fragment below shows that the access function coeff(0), instead
    of retrieving coefficient[0] simply returns the fixed value 0.0 (presumably because the
    optimizer "thinks" numvalid holds still the value 0 from the constructor and that therefore
    the comparison "if (i < numvalid)" can be omitted).
    Note: disassembly created from code compiled with -features=no%except for simplicity!
    00010e68 <___const_seg_900000102>:
            ...     holds the value 0.0
    00010e80 <__1cLtroublefunc6FpnEPoly__v_>:
       10e80:       90 90 00 08     orcc  %g0, %o0, %o0      if (pC) {   
       10e84:       02 40 00 14     be,pn   %icc, 10ed4
       10e88:       9c 03 bf 50     add  %sp, -176, %sp
                                                       local Poly object at %sp + 120
                                                             numvalid at %sp + 0xa8 (168)
       10e8c:       c0 23 a0 a8     clr  [ %sp + 0xa8 ]      Poly() { numvalid = 0; };
                                                             pC->getPoly(pol):
                                                             loop copies *pC to local Poly object
       10e90:       9a 03 a0 80     add  %sp, 0x80, %o5
       10e94:       96 10 20 30     mov  0x30, %o3
       10e98:       d8 5a 00 0b     ldx  [ %o0 + %o3 ], %o4
       10e9c:       96 a2 e0 08     subcc  %o3, 8, %o3
       10ea0:       16 4f ff fe     bge  %icc, 10e98
       10ea4:       d8 73 40 0b     stx  %o4, [ %o5 + %o3 ]
                                                             pol.coeff(0):
                                                             load double value 0.0 at
                                                             ___const_seg_900000102 in %f0
                                                             (and address of format string in %o0)
       10ea8:       1b 00 00 43     sethi  %hi(0x10c00), %o5
       10eac:       15 00 00 44     sethi  %hi(0x11000), %o2
       10eb0:       c1 1b 62 68     ldd  [ %o5 + 0x268 ], %f0
       10eb4:       90 02 a0 ac     add  %o2, 0xac, %o0
       10eb8:       82 10 00 0f     mov  %o7, %g1
                                                             store 0.0 in %f0 to stack and load it
                                                             from there to %o1/%o2
       10ebc:       c1 3b a0 60     std  %f0, [ %sp + 0x60 ]
       10ec0:       d2 03 a0 60     ld  [ %sp + 0x60 ], %o1
       10ec4:       d4 03 a0 64     ld  [ %sp + 0x64 ], %o2
       10ec8:       9c 03 a0 b0     add  %sp, 0xb0, %sp
                                                             call printf
       10ecc:       40 00 40 92     call  21114 <_PROCEDURE_LINKAGE_TABLE_+0x54>
       10ed0:       9e 10 00 01     mov  %g1, %o7
       10ed4:       81 c3 e0 08     retl
       10ed8:       9c 03 a0 b0     add  %sp, 0xb0, %sp
    Hmmm... This seems to stress this formatting tags thing to its limits...

    Thanks for confirming this.
    No, this happens neither in an Open Source package nor in an important product. This is an internal product, which is continuously developed with Sun Tools since 1992 (with incidents like this one being very rare).
    I am a bit concerned with this bug though, because it might indicate a weakness in the area of C++ inlining (after all, the compiler fails to correctly aggregate a sequence of three fairly simple inline functions, something which is quite common in our application). If, on the other hand, this is a singular failure caused by unique circumstances which we have hit by sheer (un)luck, it is always possible to work around this: explicitly defining a assignment operator instead of relying on the compiler-generated one is sufficient to make the bug go away.

  • Compiler error with default arguments and static template function

    Hi 
    The following does not compile with visual studio 2010 sp1, and compiles with gcc.
    #include <string>
    class A
    public:
       template<class T>
       static T& Get(const std::wstring&);
    class B
     public:
      void f(
        double d,
        double c =A::Get<double>(L"test"));
    int main()
        B b;
        b.f(5);
    It gives me the following error 
    error C2783: 'T & A::Get(const wchar_t *)' : could not deduce template argument for 'T'
    If I change Get to be global function and not static function of A, it compiles.

    It seems to be a compiler bug.  It fails in VS2012, but compiles in VS2013.
    For completion sake, the problem exists if A is a namespace containing Get.  But not if Get is global.
    The only solutions I can see are try to workaround the problem (make Get global) or upgrade to a newer version of VS.

  • JDBC 8.1.6.0.1 Bug with grouping function

    Hi,
    I found a bug in the JDBC 8.1.6.0.1 driver, concerning the new grouping functionality of Oracle 8.1.6. Look at the following code fragment:
    String cSelect = "SELECT DACO_VU_NAME AS DIM1, ' ' AS DIM2, TO_CHAR(DACO_VERKAUFSDATUM,'yyyymm') AS DIM_DATE, GROUPING(DACO_VU_NAME) AS DIM1GROUP, GROUPING(' ') AS DIM2GROUP, GROUPING(TO_CHAR(DACO_VERKAUFSDATUM,'yyyymm')) AS DIM_DATEGROUP, sum(DACO_BRUTTOBETRAG_TX) AS VALUE FROM DATENCONTAINER GROUP BY CUBE (DACO_VU_NAME, '-', TO_CHAR(DACO_VERKAUFSDATUM,'yyyymm') ) ORDER BY 1,2,3";
    try {
    System.out.println("SELECT: " + cSelect);
    Statement stmt = conn.createStatement();
    ResultSet rset = stmt.executeQuery(cSelect);
    while (rset.next()) {
    String cTest1 = rset.getString("DIM1");
    String cTest2 = rset.getString("DIM2");
    String cTest3 = rset.getString("DIM_DATE");
    String cChar1 = rset.getString("DIM1GROUP");
    String cChar2 = rset.getString("DIM2GROUP");
    String cChar3 = rset.getString("DIM_DATEGROUP");
    System.out.println(cTest1 + "\t" + cTest2 + "\t" + cTest3 + "\t" + cChar1 + "\t" + cChar2 + "\t" + cChar3);
    }When I compile this with the mentioned JDBC version and run it with java 1.2.2 (JDeveloper 3.1), i get the following output:
    Ahrend GmbH & Co. KG 200003 0 0 0
    Ahrend GmbH & Co. KG 200003 1 0 0
    Ahrend GmbH & Co. KG 200004 0 0 0
    Ahrend GmbH & Co. KG 200004 1 0 0
    Ahrend GmbH & Co. KG null 0 0 1
    Ahrend GmbH & Co. KG null 1 0 1
    null 200003 0 1 0
    null 200003 1 1 0
    null 200004 0 1 0
    null 200004 1 1 0
    null null 0 1 1
    null null 1 1 1As you can see, the grouping columns are mixed up. In this example, everywhere a normal row shows a "null" value, a corresponding grouping row should show a "1", but as you can see, for the last 6 rows, the ones are not in the first, but in the second grouping row.
    When I compile the example with the Oracle 8.1.5 JDBC driver, I get the following, correct, output:
    Ahrend GmbH & Co. KG 200003 0 0 0
    Ahrend GmbH & Co. KG 200004 0 0 0
    Ahrend GmbH & Co. KG null 0 0 1
    Ahrend GmbH & Co. KG 200003 0 1 0
    Ahrend GmbH & Co. KG 200004 0 1 0
    Ahrend GmbH & Co. KG null 0 1 1
    null 200003 1 0 0
    null 200004 1 0 0
    null null 1 0 1
    null 200003 1 1 0
    null 200004 1 1 0
    null null 1 1 1The special thing about this example is, that I use a constant row for grouping (row 2). If you use a normal database row, everything works fine with 8.1.6.0.1, but nevertheless, this should be a bug.
    Any comments on this are highly appreciated, since I need the JDK 1.2 for the application and I didn't find a working Oracle 1.2 JDBC version.
    Thanks,
    Thorsten.

    Patches can be obtained from an Oracle Support Services technical analyst.
    null

  • Seg fault compiling Fractal C example in ss 12.1  opensolaris 117 x64

    Hello,
    When i try to compile the Fractal example with default settings i get :
    CC -o dist/Debug/SunStudio-Solaris-x86/fractal_2 build/Debug/SunStudio-Solaris-x86/fractal.o
    CC: Fatal error in ld: Segmentation Fault (core dumped)
    ld: fatal: file /opt/sunstudio12.1/prod/lib/crti.o: section .rela.annotate has invalid type [ SHT_RELA ]
    *** Error code 1
    Compiling openjdk 7 hotspot gives me the same seg fault too.
    I'm using ss 12.1 opensolaris 117 x64 with their update managers patches applied for both products.
    Is there some possible error at my system or is it an ss bug ?

    switching to latest ss express fixed the problem.

  • Possible bug with c interop in fortran

    A colleague and I are writing some c interop examples for a book and have come across a possibe bug.
    We are testing passing 2 d arrrays (c99 vla) between fortran, c and c++.
    Fortran main program calling c function works.
    C main program calling Fortran subroutine works.
    C++ calling fortran subroutine fails.
    here is the fortran soubroutine
    subroutine reciprocal(nr,nc,x,y) bind(c,name='reciprocal')
    use iso_c_binding
    implicit none
    integer (c_int) , value :: nr
    integer (c_int) , value :: nc
    real (c_float) , dimension(1:nr,1:nc) , intent(in ) :: x
    real (c_float) , dimension(1:nr,1:nc) , intent(out) :: y
      y=1.0/x
    end subroutine reciprocal
    we compile this with
    sunf90 -c ch3110.f90 -o ch3110_f.o
    we then try compiling the following with
    sunCC ch3110.cxx ch3110_f.o
    #include <iostream>
    using namespace std;
    extern "C" void reciprocal(int nr,int nc,float x[nr][nc],float y[nr][nc]);
    int main()
      const int nr=2;
      const int nc=5;
      float x[nr][nc];
      float y[nr][nc];
      float t[]={1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0};
      int r;
      int c;
      int i=0;
      for (r=0;r<nr;r++)
        for (c=0;c<nc;c++)
          x[r][c]=t[i];
          i++;
      cout << " C++ passing a 2d array to Fortran " << endl;
      for (r=0;r<nr;r++)
        for (c=0;c<nc;c++)
          cout << x[r][c] << " ";
        cout << endl;
      reciprocal(nr,nc,x,y);
      for (r=0;r<nr;r++)
        for (c=0;c<nc;c++)
          cout << " 1 / " << x[r][c] << " = " << y[r][c] << endl;
      return(0);
    and get the following error message
    ian@linux-9624:~/document/fortran/third_edition/examples> sunf90 -c ch3110.f90 -o ch3110_f.o
    ian@linux-9624:~/document/fortran/third_edition/examples> sunCC ch3110.cxx ch3110_f.o
    "ch3110.cxx", line 5: Error: An integer constant expression is required within the array subscript operator.
    "ch3110.cxx", line 5: Error: An integer constant expression is required within the array subscript operator.
    "ch3110.cxx", line 5: Error: An integer constant expression is required within the array subscript operator.
    "ch3110.cxx", line 5: Error: An integer constant expression is required within the array subscript operator.
    "ch3110.cxx", line 36: Error: Formal argument x of type float(*)[1] in call to reciprocal(int, int, float(*)[1], float(*)[1]) is being passed float[2][5].
    "ch3110.cxx", line 36: Error: Formal argument y of type float(*)[1] in call to reciprocal(int, int, float(*)[1], float(*)[1]) is being passed float[2][5].
    6 Error(s) detected.
    ian@linux-9624:~/document/fortran/third_edition/examples>
    We get the same (or similar) error messages from
      g++ and gfortran 4.8.x
      g++ and gfortran 4.10.x
        we failed a bug report with the gnu team
        and it is reported as a duplicate of an existing bug.
      microsoft C++ and Intel fortran
        microsoft do not support C99 vla.
    The only combination that we have found that
    works is with the Intel beta versions of their
    fortran and C++ compilers.
    Any thoughts?
    Ian Chivers

    It appears to be a question of standards conformance and what standards :-(
    The gfortran and Intel C++ compilers are tracking the c99
    standard.Microsoft have stated that they will not be supporting c99 in
    their C++ compiler.
    I have found a statement that C++14 will support c99 vla.
    Jane and I have a
    c99 and Fortran 90 combination where the above syntax works.
    source code below.
    c source file
    =========
    +++++
    #include <stdio.h>
    void reciprocal(int nr,int nc,float x[nr][nc],float y[nr][nc]);
    int main()
      const int nr=2;
      const int nc=5;
      float x[nr][nc];
      float y[nr][nc];
      float t[]={1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0};
      int r;
      int c;
      int i=0;
      for (r=0;r<nr;r++)
        for (c=0;c<nc;c++)
          x[r][c]=t[i];
          i++;
      printf(" C passing a 2d array to Fortran\n");
      for (r=0;r<nr;r++)
        for (c=0;c<nc;c++)
          printf(" %f " , x[r][c]);
        printf("\n");
      reciprocal(nr,nc,x,y);
      for (r=0;r<nr;r++)
        for (c=0;c<nc;c++)
          printf(" 1 / %f = %f \n" , x[r][c],y[r][c]);
        printf("\n");
      return(0);
    +++++
    fortran source file
    =============
    subroutine reciprocal(nr,nc,x,y) bind(c,name='reciprocal')
    use iso_c_binding
    implicit none
    integer (c_int) , value :: nr
    integer (c_int) , value :: nc
    real (c_float) , dimension(1:nr,1:nc) , intent(in ) :: x
    real (c_float) , dimension(1:nr,1:nc) , intent(out) :: y
      y=1.0/x
    end subroutine reciprocal
    +++++
    this combination WORKS
    with the sun compiler suite.
    Finally you mentiion
    +++++
    Finally, when linking Fortran and C++ code, you must use the C++ compiler (CC) to do the link step, and you must use the option -xlang=f90 to get all the libraries linked in the right order:
    CC  ch3110.cxx  ch3110_f.o  -xlang=f90
    Refer to the xlang option in the C++ Users Guide for more information.
    ++++
    jane and i did not need to do the above using c interop with the other mixed language examples
    we have written and have working.
    we have a scalar parameter passing example
      fortran calling c
    c calling fortran
    c++ calling fortran
    that works with the 12.4 beta suite.
    we have a 1 d array example
      fortran calling c
      c calling fortran
      c++ calling fortran
    working with the 12.4 beta suite.
    I was under the impression that
    sunCC
    pointed to the sun C++ compiler.
    so from your reply I assume that our example will not work with the current
    sun/oracle C++ compiler, but may work if sun track the C++14
    standard.
    here is the source code for our 1d fortran C++ combo
    c++
    ===
    #include <iostream>
    using namespace std;
    extern "C" float summation(float *,int );
    int main()
      const int n=10;
      float *x;
      int i;
      x = new  float[n];
      for (i=0;i<n;i++)
        x[i]=1.0f;
      cout << " C++ passing an array to Fortran " << endl;
      cout << " Sum is " << summation(x,n) << endl;
      return(0);
    Fortran
    =====
    function summation(x,n) bind(c,name='summation')
    use iso_c_binding
    implicit none
    integer (c_int) , value :: n
    real (c_float), dimension(1:n) , intent(in) :: x
    real (c_float) :: summation
    integer :: i
      summation=sum(x(1:n))
    end function summation
    this fortran C++ combo works.
    Notes
    ====
    From the reply we got from the gnu team they wil be implementing
    the functionality at some point.
    Intel already does in their beta.
    Microsoft will not as they are not tracking
    c99.
    Thanks for you time.

  • [Bug] Compiler bug in JDev  10.1.3.0.4 (SU5)

    Hello,
    I would like to report a bug with Java 5 compiler in JDev 10.1.3.0.4 (SU5) build JDEV_ADF_10.1.3_NT_030125.0900.3673 regarding covariant return types.
    As of Java 5, it's now possible to override a method with a different return type as long as the new return type is a subclass of the overridden method's return type. JDeveloper compiler will manage that correctly (no compilation error), but will result in a java.lang.AbstractMethodError if the overriding definition come from an interface.
    So the reproduction case is :
    public interface Interface1 {
       public Object myMethod();
    public interface Interface2 extends Interface1 {
      public String myMethod();
    public abstract class AbstractInterface2 implements Interface2 {
    public class MyClass extends AbstractInterface2 {
      public String myMethod() {
        return "Hello"!;
    public static void main(String... args) {
      Interface1 myObject = new MyClass();
      myObject.myMethod();
    }I did not test with other JDev version.
    Regards,
    Simon Lessard

    quick workaround is to set project output directory to the WEB-INF/classes directory and compile the jsp from jdeveloper, oc4j then updates the loaded class file without re-compiling the jsp.
    This works fine, but if I let OC4J try to compile the JSP problem still occurs, anyone have any ideas why either of these problems occur?

Maybe you are looking for

  • Mail wont download emails

    The account checks out fine, even in the connection doctor but when I try to get new mail it starts to download then trickles down to 0kbps and sits there and after a while Mail just gives up and acts like it finished downloading when it really hasn'

  • Is there a way of going through Swing objects and changing properties?

    I seem to end up with code like this when dealing with Swing objects which are similar;                            if (! ThrottleProperties.getProperty("Lever.1").equals("Disabled")) jTextFieldLever1.setText("" + USBData[0]);                         

  • What should I do?

    Okay so I feel incredibly stupid. I just bought an iPhone 5 on the 26th, and the battery drained so fast, and I was expecting much better for an iPhone. So, I jump to conclusions, and find out I should try to restart the phone with DFU (I think that'

  • How to install CS5.5 into Macpro OS 10.8 Mountain Lion? anyone please help

    How to install CS5.5 into Macpro OS 10.8 Mountain Lion? anyone please help

  • Comparison of ESR Object ID/Object Version ID between PI Environments

    Does anyone know how can I compare ESR Object ID/Object Version ID between PI Environments (lets say PI-DEV vs. PI-QA)? Is there a way to do it in mass? This is to make sure that actually all the correct object versions have been transported. May be