stdcxx-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martin Sebor (JIRA)" <j...@apache.org>
Subject [jira] Created: (STDCXX-861) [Sun C++ 5.9/x86_64] bad codegen on va_arg and long double
Date Mon, 14 Apr 2008 03:11:05 GMT
[Sun C++ 5.9/x86_64] bad codegen on va_arg and long double
----------------------------------------------------------

                 Key: STDCXX-861
                 URL: https://issues.apache.org/jira/browse/STDCXX-861
             Project: C++ Standard Library
          Issue Type: Bug
          Components: External
            Reporter: Martin Sebor


Sun C++ 5.9 appears to generate incorrect code for x86_64 (but not for x86 or SPARC) the attached
program involving va_arg() and long double.

{noformat}
$ cat t.cpp && CC -m64 -V t.cpp && ./a.out
#include <cassert>
#include <cstdarg>
#include <cstdio>
#include <cstring>

char buffer [80];
const char* a1;
int a2;
const char* a3;
int a4;
const char* a5;
long double a6;

void setargs (std::va_list va) {
    a1 = va_arg (va, const char*);
    a2 = va_arg (va, int);
    a3 = va_arg (va, const char*);
    a4 = va_arg (va, int);
    a5 = va_arg (va, const char*);
    a6 = va_arg (va, long double);
}

void foo (const char *fmt, ...) {
    std::va_list va;
    va_start (va, fmt);
    setargs (va);
    std::sprintf (buffer, "%s %x %Lg", a3, a4, a6);
    va_end (va);
}

void bar (char *buf, const char *fmt, ...) {
    std::va_list va;
    va_start (va, fmt);
    setargs (va);
    std::sprintf (buf, "%s %x %Lg", a3, a4, a6);
    va_end (va);
}

int main () {
    char buf [80];

    foo (     "", "", 1, "", 0x12345678, "%Lg", 1.0L);
    bar (buf, "", "", 1, "", 0x12345678, "%Lg", 1.0L);

    std::puts (buffer);
    std::puts (buf);

    assert (0 == std::strcmp (buf, buffer));
    assert (0 == std::strcmp (buf, " 12345678 1"));
}
CC: Sun C++ 5.9 SunOS_i386 Patch 124864-01 2007/07/25
/amd/packages/mdx/solaris/amd64/compilers/sun/C++5.9j1/prod/bin/c++filt: Sun C++ 5.9 SunOS_i386
2007/05/03
ccfe: Sun C++ 5.9 SunOS_i386 Patch 124864-01 2007/07/25
ld: Software Generation Utilities - Solaris Link Editors: 5.10-1.482
 12345678 1
 12345678 2.60544e-4932
Assertion failed: 0 == std::strcmp (buf, buffer), file t.cpp, line 48
Abort (core dumped)
{noformat}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message