Code generation bug in Sun Studio 12

Hi,
The following program prints `Failure' when compiled with -xO4 where nothing should be printed (when compiled with no optimization or -xO2). It looks to me that the first comparison `buggy_routine' against 0x80 is returning True where it should return False.
#include <stdlib.h>
#include <stdio.h>
typedef unsigned long long int      EIF_NATURAL_64;
typedef unsigned char   EIF_BOOLEAN;
typedef int EIF_INTEGER_32;
typedef char * EIF_REFERENCE;
char s[] = "9223372036854775808";
void buggy_routine (EIF_REFERENCE Current, EIF_NATURAL_64 arg1)
    EIF_NATURAL_64 tu8_1;
    tu8_1 = (EIF_NATURAL_64) ((EIF_INTEGER_32) 128L);
    if ((EIF_BOOLEAN) (arg1 <= tu8_1)) {
    } else {
        if ((EIF_BOOLEAN) (arg1 <= ((EIF_NATURAL_64)  9223372036854775808ull ))) {
        } else {
              printf("Failure\n");
int main (int argc, char ** argv, char **envp ) {
    EIF_NATURAL_64 loc2 = (EIF_NATURAL_64) 0;
    loc2 = (EIF_NATURAL_64) atoll(s);
    buggy_routine ("s", loc2);
}To reproduce:
cc -xO4 bug.c -o bug ; ./bug
It fails on both 32 and 64-bit code generation for x86. I haven't tried on Sparc as I need to install Sun Studio 12. Is this a known issue? Is there an easy workaround?
I tried with Sun Studio 11 and it worked just fine there.
Regards,
Manu
PS: I've tried with both version (the first is the one from the default installation) and the second after I noticed there were some patches available:
cc: Sun C 5.9 SunOS_i386 Patch 124868-01 2007/07/12
cc: Sun C 5.9 SunOS_i386 Patch 124868-02 2007/11/27

An issue filed at bugs.sun.com does not go directly into the bug database. It is evaluated, and if it turns out the report is actually a bug not previously reported, goes into the database. You get a notification and chance to reply after the report is evaluated.
In this case, I picked up your report myself, and filed the bug. The bug ID is 6654314, and will be visible at bugs.sun.com in a day or two.

Similar Messages

  • Code generation bug in C++ 5.0

    The enclosed test program generates incorrect code
    with C++ 5.0 when -g is not used.
    The problem showed up in our production code
    and concerns any reference counted smart pointer
    implementation.
    The test program is specifically written to demonstrate
    the problem and diagnose a reference miscount.
    With any optimization at all (without -g, and/or with
    any level of -O including no -O) it generates
    incorrect results. With -g the results are correct.
    gcc compiles this correctly with any optimizations
    selected.
    // main.cc
    // test program to demonstrate code generation bug in
    // Sun WorkShop Compilers C++ 5.0
    // bug exhibited as of 27th April 2001
    // relevant patches applied:
    // 107289-05 Packages: SPROcc
    // 107390-12 Packages: SPROtl7x, SPROsclx, SPROtll7x, SPROcplx, SPROlgcx
    // 107311-12 Packages: SPROscl, SPROtll7, SPROtlbn7, SPROcpl, SPROgc, SPROlgc
    // 107357-11 Packages: SPROlang
    // correct behaviour with CC -g:
    // CC -g main.cc -o main; ./main
    // incorrect behaviour with CC (no -g):
    // CC main.cc -o main; ./main
    #include <stdio.h>
    class O {
    public:
    inline O() : m_refCount(0) { };
    inline void ref() { m_refCount++; }
    inline void deref() { m_refCount--; }
    inline int refCount() { return(m_refCount); }
    private:
    int m_refCount;
    class R {
    public:
    inline R() : m_object(0) { };
    inline R(const R &r) : m_object(r.m_object) { if (m_object) m_object->ref(); }
    inline R(O *o) : m_object(o) { if (o) o->ref(); };
    inline ~R() { if (m_object) m_object->deref(); }
    inline R &operator =(const R &r) {
    if (this == &r) return(*this);
    O *o = m_object;
    if (m_object = r.m_object) m_object->ref();
    if (o) o->deref();
    return(*this);
    inline R &operator =(O *n) {
    if (m_object == n) return(*this);
    O *o = m_object;
    if (m_object = n) n->ref();
    if (o) o->deref();
    return(*this);
    inline operator O *() const { return(m_object); }
    inline O *operator ->() const { return(m_object); }
    private:
    O *m_object;
    class B {
    public:
    inline B(const R &r) : m_ref(r) { };
    inline const R &ref() { return(m_ref); }
    private:
    R m_ref;
    R buggy(int notnull, B &b)
    return(notnull ? b.ref() : 0); // BUG HERE
    int main()
    O o;
    R r(&o);
    B b(r);
    int i;
    for (i = 0; i < 20; i++) {
    R s;
    s = buggy(!0, b);
    printf("refCount: %d (should be 2)\n", o.refCount());

    How do I file a bug report for this and get
    a bug ID assigned?

  • Code Generation Bug in Forms 10g

    We're hitting this goofy bug in Forms 10g (also occurs in 9i) code generation of the On-xxx triggers. I have an "obj" package that declares an index-by array type that's used by multiple packages, including a "qry" package and "dml" package (in good ol' Steven Feuerstein tradition). The On-xxx triggers pass this type into packaged procedures that perform the Insert, Update, Delete and Lock required by Forms. These DML routines are in the "dml" package.
    When we look at the generated trigger code, we see that the index-by array type is incorrectly referenced as dml.obj.idx. That is, since the On-xxx trigger is calling DML routines in the "dml" package, it's improperly qualifying the reference with the dml package name. The On-xxx trigger code gets regenerated every time we do Compile Module. We tried doing Compile All, which doesn't regenerate the On-xxx triggers; but neither does it produce an fmx file.
    Is this a known bug, and is there a workaround? I can't move the index-by array type declaration to the dml package because it's used by multiple packages. If I fix it in one place, I break it in another. I can't have multiple declarations of this type in multiple packages either, because I'm passing it around between the packages, and they're not type-compatible at that point.

    It looks like the Forms Wizard is the real culprit. When we looked at the Property Palette for each On-xxx trigger, where the target procedure is specified, along with the parameters, is where the malformed dml.obj.ref code appears. Once we edited those entries, the On-xxx triggers generated correctly.

  • -nodisplay bug with Sun Studio 10 for Linux installer

    I'm currently trying to install a trial Sun Studio 10 for Linux on a Fedora Core 3 box. I want the installer to run via the command line, so I use "./installer -nodisplay", but I get the following error message:
    java.lang.UnsatisfiedLinkError: /home/pacey/SS10/.install/jvm_1.4.2/j2re1.4.2_06/lib/i386/libawt.so: libXp.so.6: cannot open shared object file: No such file or directory
    libXp is part of the X window system, but I've specified -nodisplay. A non-graphics option shouldn't be trying to load graphics libraries - looks like a bug. Anyway, as I don't have version 6 of that lib on my system, I'm stalled on this. Any suggestions?

    I'm currently trying to install a trial Sun Studio 10 for Linux on a Fedora Core 3 box. I want the installer to run via the command line, so I use "./installer -nodisplay", but I get the following error message:
    java.lang.UnsatisfiedLinkError: /home/pacey/SS10/.install/jvm_1.4.2/j2re1.4.2_06/lib/i386/libawt.so: libXp.so.6: cannot open shared object file: No such file or directory
    libXp is part of the X window system, but I've specified -nodisplay. A non-graphics option shouldn't be trying to load graphics libraries - looks like a bug. Anyway, as I don't have version 6 of that lib on my system, I'm stalled on this. Any suggestions?

  • How to report bugs for Sun Studio 12 update 1?

    I want to report a bug for the Sun Studio 12u1 C compiler, but bugreport.sun.com doesn't know about Sun Studio 12u1. The latest release know is SS12.
    Furthermore, the form doesn't allow to attach additional files, e.g. sources and other information needed to reproduce the problem.
    Since we have a valid service support contract with Sun, I used the official channel via the member support center, on January 15. Now, one month later, there is still no answer - and searching the databases both on sunsolve and bugreport.sun.com show, that my report hasn't gotten that far, yet.
    I really like Sun Studio, and I use it both for research and education, but reporting issues is really a problem. This somehow spoils the fun, both for the end users and the developers of a really great product!
    So the big question is: What is the best and quickest way to get bugs reported?
    Regards,
    Bernd

    If you have a support contract, the best way is to report via official channel; this is the only way to ensure that the bug is fixed in a patch for already released product. The fact that you can't find your report on sunsolve and bugreport.sun.com does not mean anything: not all bugs are public for obvious reasons.
    I think you should request an update via the same official channel; if you get nothing in a reasonable time (a day, I think), please report back here, we'll try to find out what's going on.

  • Code generation bug

    Hi,
    I have the following version of `cc':
    cc: Sun C 5.7 Patch 117837-05 2005/07/19
    Here is the file `bug.c':
    #include <stdlib.h>
    #include <stdio.h>
    void my_buggy_routine (char * Current, int arg1) {
    int loc1 =-arg1;
    if ((unsigned char)(loc1 == ((int) 0x80000000L))) {
    loc1 = -(loc1 / ((int)10L));
    printf ("Value is %d.\n", loc1);
    int main (int argc, char ** argv, char **envp ) {
    if (argc > 1) {
    my_buggy_routine (NULL, atoi (argv[1]));
    If you perform the following command line:
    cc -xO2 bug.c -o bug ; bug -2147483648
    You expect to get:
    Value is 214748364
    However you get:
    Value is -214748364
    If you remove the optimization when compiling then everything works fine.
    I've noticed that if I change the line:
    if ((unsigned char)(loc1 == ((int) 0x80000000L))) {
    by
    if (loc1 == ((int) 0x80000000L)) {
    then it works fine.
    Is it a known bug?
    Regards,
    Manu

    I forgot to say that it was on Solaris 10 for x86 running on a AMD64. Both 32bits and 64bits version of the program exhibit the problem.
    I've tried on Solaris Sparc with:
    cc: Sun C 5.7 2005/01/07
    and it works fine.
    Regards,
    Manu

  • Multiple POST-MAPPING Processes Code Generation BUG

    We are testing OWB 10gR2, and we were very happy to see that there is option to include more than one postmapping operator.
    The idea is to create mapping with two post-mapping operators and that:
    - one procedure is executed in case of 'Post-Mapping Process Run Condition' = ON ERROR
    - and other procedure in case of 'Post-Mapping Process Run Condition' = ON SUCCESS.
    But, after implementation of this case, we were dissapointed. We discover that neither procedure is executed.. ?!?!
    After analyzing generated code in 'finalize' method there is code like this:
    IF NOT get_abort THEN
    IF get_abort THEN
         BEGIN
    As you can see this condition will never bee true ?!?
    Doe's anyone have same problem?

    1) If you have somehow got multiple post-mappings working, I would consider that to be buggy behaviour that you cannot depend on for future releases or upgrades. As such, building a solution that depends on this has risk.
    2) You could always build a user-defined custom transformation that takes a list of tables to truncate and does so. Something like (untested, uncompiled, seat-of-the-pants written right here example to get you started):
    create or replace procedure trunc_tables(tablist varchar2)
    is
    local_tablist varchar2(2000) := tablist;
    this_Table varchar2(30);
    nextindex number := 1;
    begin
    nextindex := instr(local_tablist,',');
    while nextindex != 0 loop
    this_table := substr(local_tablist,1,nextindex-1);
    execute immediate 'truncate table '||this_Table;
    local_tablist := substr(local_tablist,nextindex+1);
    nextindex := instr(local_tablist,',');
    end loop;
    -- if no trailing semicolon there is still one table left
    if length(local_tablist) > 0 then
    execute immediate 'truncate table '||local_tablist;
    end if;
    end;
    You could then reference this in your post-mapping procedure with a call to trunc_Tables('table1,table2,table3'), and could re-use this code across all mapping that need it.
    Of course, if you have a lot of mapping-specific stuff to do then you might need to build custom transformations for each mapping that need to do different things as part of their post-process.
    Mike

  • Sun Studio 12 Update1 and OpenMP

    Hi guys,
    I was using the Sun Studio 12 with OpenMP and everything was OK. So I decide to download the update 1 (which is OpenMP 3.0 full compliance), however I am getting linking error.
    Below is the message:
    Undefined first referenced
    symbol in file
    __mt_MasterFunction_cxt_ build/Debug/SunStudio_12.1-Solaris-x86/a1.o
    I look into my libmtsk.so libraries and I could see that __mt_MasterFunction_cxt_ really does not exist.
    So I believe this is a bug on Sun Studio 12 Update 1 that didn't install the last library. Anyway, I am try to find out where to get this library or any patch to it. I did try to get the patch 120754. However the site is pointing that I has no support contract. What is true just because I am a student, and I am just learning things for now...:-)
    Hope someone can help me with that..
    Thanks and Regards

    I cannot download any patch because I do not have any support contract.Last time I tried, Solaris patches were free, at least those related to compiler components.
    Byt the way, I rarely install the product myself, but I had an impression that Solaris version comes together
    with patches, which are intended to be installed right upon the installation.
    I'm sorry for the lost hours of precious time, but that seems to be more like your navigational error,
    rather than the intentional attempt from Sun to decieve you.
    Believe me or not, we made Sun Studio free because we want developers to use it, not because
    we hope to catch you offguard and cut some money.
    I should get opensolaris if I want a "linux like license and support"And that is true.
    If you do not like the way Solaris patches are managed (and, many think that it is a mess) you might better like Opensolaris.
    You also might want to try Linux version, it is as close to Solaris version functionality-wise as possible.
    I will just uninstall my sun studio 12 update 1 and go back to the sun studio 12 (where no patches are needed to run the openmp 2.5).Sun Studio 12 got no interface change thus no patches were needed to run OpenMP 2.5 as soon as you have libmtsk.so installed.
    Quite contrary, SS12u1 got OpenMP 3.0, which is substantially different to OpenMP 2.5 and that warranted interface change in runtime support
    (libmtsk.so).
    Trying to create "partial open source" things is not that good. First, it is not open source yet :-), it is just free.
    Then, if we would do partial thing (which is not that bad per se, surely depending on how you do it), that would definitely be written in caps all around.
    And broken functionality is definitely not the way Sun does its business.
    regards,
    __Fedor.

  • Sun Studio code hangs at fork, GCC code runs fine

    I am encountering a strange problem where code complied with GCC runs fine, but the same code compiled with Sun Studio 12 compiler hangs at a fork call after an initial set of fork calls.
    I'd appreciate your help in solving this.
    The code was originally written for GCC, I started using the Sun Studio with a view to using Sun's thread analyzer. I made a couple of changes which I think are inoccuous:
    (a) added #ifdef __SUNPRO_CC char * __FUNCTION__ = "name"; #endif
    (b) one more #ifdef around one call to ctime_r because the g++ include expects 2 parameters while Sun Studio 12 expects 3 parameters.
    The g++ is compiled on a Solaris 9 (1 x sparcv9) using GCC 3.3.3
    while the Sun Studio 12 is on a Solaris 10 ( 4 x sparcv9).
    Both runs were on the same Solaris 10 machine which has the compiler.
    The program is a multi instance socket listener, the main program binds to a socket, then forks off a set of processes which accept connections, those children later fork off other client applications based on the connection data; after those clients exit, the children continue accepting etc. The main program only monitors the child processes, records their status and starts if any of those die.
    This is working as expected when compiled with g++.
    The exact same code (note the two sets of #ifdefs above) when compiled with Sun PRO CC alway hangs at the second set of fork. That is, it goes through the first set of forks fine, then when a connection is established, it reads the data but hangs right at the fork call.
    The application code at this point is:
    char * p = pathfind( getenv("PATH"), progname );
    if ( !p ) {  printError(); return false; }
    pid = fork();
    The truss for the Sun Studio code shows
    23914: access("/usr/bin/progname", X_OK) = Err#2 ENOENT
    23914: access("/usr/you/bin/progname", X_OK) = 0
    23914: lwp_park(0x0000000, 0) (sleeping)
    while the truss for the g++ code shows
    23986: access("/usr/bin/progname", X_OK) = Err#2 ENOENT
    23986: access("/usr/you/bin/progname", X_OK) = 0
    23996: fork1() = 24005
    What am I doing wrong?
    Thanks and best regards

    If I understand correctly, you are compiling with gcc on Solaris 9, and with Sun Studio on Solaris 10. Since the OS is different, you might be running into OS issues and not compiler issues. What happens if you build with the same gcc version on the Solaris 10 system where you see the problem?
    By "OS issues", I mean
    1. The program uses unstable or undocumented OS interfaces, or
    2. A bug that is new in Solaris 10.
    A bug was identified in Solaris 10 that could cause forks to hang. It showed up in the libpkcs11 library as used by the JVM. I don't know whether it showed up elsewhere.
    This bug was fixed in Solaris 10u2. If you are using an earlier version of Solaris 10, you could try upgrading.

  • Installed Sun studio 12.2. ran 'discover' command on C++ code.Gives warning

    Hi,
    I installed Sun studio 12.2. I compiled C++ code with C++ 5.11 compiler, and ran discover command as shown below:
    > #CC -g -O2 test.cpp
    > #discover -w - a.out
    > discover (warning): a.out will be analyzed in lite mode because it has no annotations. See discover documentation for compiler flag/OS recommendations
    I get the discover warning. After runnig discover command, I executed ./a.out. On cosole, only memory leaks will be displayed and no other error.
    Any reason why discover gives warning??????????????????
    Edited by: Archit on Apr 5, 2011 11:09 PM
    Edited by: Archit on Apr 5, 2011 11:10 PM
    Edited by: Archit on Apr 5, 2011 11:10 PM
    Edited by: Archit on Apr 5, 2011 11:13 PM

    Hi,
    What a woderful fix you have provided !!!!!!!!!!
    It really works.
    I tried running on Solaris 10 update 8. discover tool runs properly. Where as , the tool runs in lite mode on Solaris update 4.
    If possible , can you pint me to some links where I can this kind of info.?
    Thank you very much.

  • Another bug in sun one studio?

    is this another bug in sun one studio or something else.
    i have set the author to a different name through
    tools -> options -> java sources
    but when i create session beans or cmp beans, it uses the previous name.
    however java main classes display the new name

    This looks like a bug to me. I didn't see anything in the bug database that was similar, so I would suggest that you file a bug at:
    http://java.sun.com/webapps/bugreport/
    using:
    Category: Sun Java Studio, Sun ONE Studio, Forte for Java
    SubCat: EJB Components

  • Automatic Code generation from UML for C++ in Visual Studio 2013 Ultimate

    Hi all, 
    I am using Visual Studio 2013 Ultimate to design UML diagrams and want to use the class diagram to generate C++ code,
    however I found that there seems only support C# generation.
    Is there any way to do the code generation (even round-trip engineering with C++/UML model) from Visual Studio 2013 Ultimate?
    There is a way to do C++ code generation by customize the text template file right? but it is time consuming and we don't have much time to do it.:( 
    Thanks a lot!

    Hello Grib,
    >>is there anyway to integrate an STE code generator to Visual Studio 2013. I know there is EF5.x STE Generator but only for VS 2012.
    Yes, you can.
    Since the STEs are T4 template and you can just take template and code any changes or improvements you require yourselves! As you mentions, there is a EF5.x STE generator, you could download it and edit it. You could check this article:
    Upgrading to EF6, we could see that from EF5 to EF6, the team moves classes to a new namespace, so we need to modify the T4 template to generate the new namespace.
    Regards.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Are there serious bugs with SUN one studio

    sometimes when I an trying to perform some particular type of operations in SUN one studio community edition on my pentium III 600MHz 256MB RAM system, SUN one studio vapourises from the deskop even faser than it does when u exit normally, i changed platform to Linux installing the linux binaries..the same problem also occurs..I heppens usually when i right click on a package trying to add new bean, or JSP or some other features
    Well i hope it is not my own machine that is bugging SUN studio
    Thanks

    I do but it still retains the same problem. I have jdk1.4.1 and yet it just vaporises from my desktop. Do SUN one studio have serious memory conflict with certain processes or what.

  • Tcov Code Coverage Libraries missing from Sun Studio 12!!!

    Hi,
    When I try to collect coverage statistics using the -xprofile=tcov I get the following message
    f90     -xprofile=tcov -w0 -C  -c ./intfaces.f90 -o ./scovintfaces.o
    f90     -xprofile=tcov -w0 -C  -c ./gcovsrc.f90 -o ./scovsrc.o
    f90     -xprofile=tcov -w0 -C  -c ./gcovdrv.f90 -o ./scovdrv.o
    f90      -xprofile=tcov -w0 -C  -o ./five82scov.exec ./scovdrv.o ./scovsrc.o /usr/lib/libg2c.so.0 
    f90: Cannot find /opt/sun/sunstudio12/prod/lib/bb_link.oThis file does not seem to be within the packages provided in sun studio 12!!! (linux/x86 editon). I then decided to get the latest patches and now I get the following message
    f90     -xprofile=tcov -w0 -C  -c ./intfaces.f90 -o ./scovintfaces.o
    /opt/sun/sunstudio12/prod/bin/f90comp: error while loading shared libraries: libyabe.so: cannot open shared object file: No such file or directoryThis file is also nowhere to be found!!! Have the sun developers decided to leave out crucial libraries?!?
    Regards

    This is not very nice from the compiler, but at least it is documented here:
    http://developers.sun.com/sunstudio/documentation/ss12/mr/READMEs/fortran_95.html#limitations
    Quote:
    The -xprofile=collect and -xprofile=tcov options should not be used when building shared libraries on Linux.

  • I want to complie code with -xO4 using sun CC(sparc) , have some risk?

    i will upgrade which patch? thanks.
    env��Solaris 8 2/04 WS6U2
    108434-13 �C 32-Bit Shared library patch for C++
    4199587 4205763 4271402 4285270 4318566 4338406 4347621 4351467 4353299 4358182 4368974
    4375346 4380359 4381048 4383064 4384942 4386796 4388216 4391089 4398422 4409167 4413674
    4418755 4423447 4432338 4448928 4462258 4466915 4467478 4485163 4486320 4493832 4496576
    4496848 4518910 4520126 4522461 4528281 4531069 4589227 4614582 4618537 4619221 4619891
    4624113 4627871 4641533 4660290 4668167 4679619 4680478 4686364 4709155 4710815 4302954
    4698028 4699194 4704604 4708982 4745600 4747931 4749398 4749628 4750936 4756106 4794587
    4797953 4806782 4820555 4851358 4825898 4828443 4853946 4856138 4861853

    The shared library patch includes libraries that you link to your application, including /usr/lib/libCrun.so.1, /usr/lib/libCstd.so.1, and /usr/lib/libiostream.so.1 among others. These libraries are not affected by and have no effect on compile-time optimization levels like -xO4. You should update the libraries if you want to get bug fixes.
    Note, however, that WS6u2 does not by default link to the shared libraries in /usr/lib. By default it links to static libraries (except for libCrun.so.1) in the compiler installation area. We changed this default in the next release because you should always link to the shared library. The C++ Users Guide has instructions on how to modify the compiler installation so that the shared libraries will be linked by default.
    WS6u2 is End Of Life, and little support is available for it. Early compilers like this one tended to be buggy at high optimization levels. If you get all current compiler patches, available at
    [http://developers.sun.com/sunstudio/downloads/patches/index.jsp]
    you will reduce the chances of buggy code generation.
    But the advice from Maxim is best: Upgrade to a recent compiler, Sun Studio 11 in your case. It has the benefit of years of development in the code generators, for one thing. For another, the set of tools is much improved, and the compilers support modern chips and OS versions. You should also get the current patches for Studio 11. Studio 11 is free for all uses, and you can get it here:
    http://developers.sun.com/sunstudio/products/previous/11/index.jsp
    We would normally recommend Sun Studio 12, but it does not support Solaris 8 (which is End Of Life as well.)

Maybe you are looking for