public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/51364] New: C++ interoperability with ISO-C extension DFP types requires explicit typedefs.
@ 2011-11-30 18:58 rsa at us dot ibm.com
  2011-11-30 19:09 ` [Bug c++/51364] " redi at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: rsa at us dot ibm.com @ 2011-11-30 18:58 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51364

             Bug #: 51364
           Summary: C++ interoperability with ISO-C extension DFP types
                    requires explicit typedefs.
    Classification: Unclassified
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: rsa@us.ibm.com


The following code requires explicit typedefs for _Decimal[32|64|128] in C++
programs in order to be able to use the ISO-C extension DFP types.

#include <errno.h>
#include <decimal>
#include <stdio.h>
#include <dfp/stdlib.h>

int main()
{
  char buffer[] = "0.0";
  _Decimal64 x = -1.0DD;
  errno = 0;
  x = strtod64(buffer, NULL);
  printf("%0.16De\n", x);
  return 0;
} 

/opt/at4.0/bin/g++ -g -isystem/opt/at4.0/include/c++/4.5.4/decimal
-D__STDC_WANT_DEC_FP__ strtod.cpp -ldfp -o d
In file included from strtod.cpp:9:0:
/opt/at4.0/include/dfp/stdlib.h:37:8: error: '_Decimal32' does not name a type
/opt/at4.0/include/dfp/stdlib.h:42:8: error: '_Decimal64' does not name a type
/opt/at4.0/include/dfp/stdlib.h:47:8: error: '_Decimal128' does not name a type
...

This is solved be declaring the following prior to the inclusion of
<dfp/stdlib.h> (which is where the _Decimal types are first encountered):

typedef float _Decimal32 __attribute__((mode(SD)));
typedef float _Decimal64 __attribute__((mode(DD)));
typedef float _Decimal128 __attribute__((mode(TD)));

Should these typedefs be implicitly defined when using the std::decimal
namespace?


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2012-01-18 20:00 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-30 18:58 [Bug c++/51364] New: C++ interoperability with ISO-C extension DFP types requires explicit typedefs rsa at us dot ibm.com
2011-11-30 19:09 ` [Bug c++/51364] " redi at gcc dot gnu.org
2011-11-30 21:46 ` rsa at us dot ibm.com
2011-11-30 21:46 ` janis at gcc dot gnu.org
2011-11-30 21:59 ` janis at gcc dot gnu.org
2011-12-09 16:06 ` rsa at us dot ibm.com
2011-12-17 21:14 ` mingodad at gmail dot com
2011-12-18  6:28 ` janis at gcc dot gnu.org
2011-12-19  0:10 ` mingodad at gmail dot com
2011-12-19  0:27 ` redi at gcc dot gnu.org
2011-12-19  3:33 ` mingodad at gmail dot com
2011-12-19 20:45 ` janis at gcc dot gnu.org
2012-01-18 20:21 ` rsa at us dot ibm.com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).