public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/54451] New: c++11/random.cc build failure when _GLIBCXX_USE_C99_STDINT_TR1 is not defined in config.h
@ 2012-09-01 12:01 andris.pavenis at iki dot fi
  2012-09-09  2:36 ` [Bug libstdc++/54451] " rbmj at verizon dot net
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: andris.pavenis at iki dot fi @ 2012-09-01 12:01 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 54451
           Summary: c++11/random.cc build failure when
                    _GLIBCXX_USE_C99_STDINT_TR1 is not defined in config.h
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: andris.pavenis@iki.fi


When _GLIBCXX_USE_C99_STDINT_TR1 defined in config.h neither of bits/random.h
and bits/random.tcc gets included and as result c++11/random.cc does not
compile:

random.cc:72:3: error: 'random_device' has not been declared

Noticed that when trying to build recent SVN version as Linux to DJGPP
cross-compiler. Tested versions 2012-08-30 and later.

Commenting out '#ifdef _GLIBCXX_USE_C99_STDINT_TR1' fixed build problem, but
I'm not sure that it is correct solution.


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

* [Bug libstdc++/54451] c++11/random.cc build failure when _GLIBCXX_USE_C99_STDINT_TR1 is not defined in config.h
  2012-09-01 12:01 [Bug libstdc++/54451] New: c++11/random.cc build failure when _GLIBCXX_USE_C99_STDINT_TR1 is not defined in config.h andris.pavenis at iki dot fi
@ 2012-09-09  2:36 ` rbmj at verizon dot net
  2012-09-09 11:45 ` paolo.carlini at oracle dot com
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rbmj at verizon dot net @ 2012-09-09  2:36 UTC (permalink / raw)
  To: gcc-bugs

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

rbmj at verizon dot net changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rbmj at verizon dot net

--- Comment #1 from rbmj at verizon dot net 2012-09-09 02:36:26 UTC ---
I can confirm that the build fails as reported.

A bit of searching - turns out that acinclude.m4 has the following:

if test x"$glibcxx_cv_c99_stdint_tr1" = x"yes"; then
  AC_DEFINE(_GLIBCXX_USE_C99_STDINT_TR1, 1,
            [Define if C99 tyeps in <stdint.h> should be imported in
             <tr1/cstdint> in namespace std::tr1.])
fi

This is confirmed in include/tr1/cstdint:

#ifdef _GLIBCXX_USE_C99_STDINT_TR1

namespace std _GLIBCXX_VISIBILITY(default)
{
namespace tr1
{
  using ::int8_t;
  using ::int16_t;

etc.  However, this is also in include/c_global/cstdint:

#ifdef _GLIBCXX_USE_C99_STDINT_TR1

namespace std
{
  using ::int8_t;
  using ::int16_t;

etc.  Those are the only uses of it in code that I can find.  It seems like it
isn't exactly the best name for the define (it no longer just applies to TR1),
but it doesn't do too much.  I can't think of a case where this would not be
desired behavior (I don't remember, but I *think* that the C++ standard says
that those typenames should be in the standard namespace).

Anyway, it doesn't appear like removing that code will have any adverse
effects.

The relevant code is coming from revision 150312 (written by Paolo Carlini in
2009).  Since this just broke, I'm *guessing* that this is because of 4.8
moving more towards c++11, and because it was thought that this define was only
for tr1, it was removed from a default define set *somewhere* (I'm too scared
to venture too far into the build system...).  I can't seem to find any
evidence of this though... I know it worked ~3 months ago, but my git foo can't
seem to find the change.


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

* [Bug libstdc++/54451] c++11/random.cc build failure when _GLIBCXX_USE_C99_STDINT_TR1 is not defined in config.h
  2012-09-01 12:01 [Bug libstdc++/54451] New: c++11/random.cc build failure when _GLIBCXX_USE_C99_STDINT_TR1 is not defined in config.h andris.pavenis at iki dot fi
  2012-09-09  2:36 ` [Bug libstdc++/54451] " rbmj at verizon dot net
@ 2012-09-09 11:45 ` paolo.carlini at oracle dot com
  2012-09-09 11:50 ` redi at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-09-09 11:45 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |drepper.fsp at gmail dot
                   |                            |com

--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-09-09 11:44:45 UTC ---
If it's not defined, it means that the configure time tests fails because the
target doesn't support the feature. In general - even for stdint which is
supported by most targets now - we should simply make sure that the build works
in both cases, simply the <random> features may end up not being available.

Adding Ulrich in CC, something needs tweaking in his recent work.


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

* [Bug libstdc++/54451] c++11/random.cc build failure when _GLIBCXX_USE_C99_STDINT_TR1 is not defined in config.h
  2012-09-01 12:01 [Bug libstdc++/54451] New: c++11/random.cc build failure when _GLIBCXX_USE_C99_STDINT_TR1 is not defined in config.h andris.pavenis at iki dot fi
  2012-09-09  2:36 ` [Bug libstdc++/54451] " rbmj at verizon dot net
  2012-09-09 11:45 ` paolo.carlini at oracle dot com
@ 2012-09-09 11:50 ` redi at gcc dot gnu.org
  2012-09-09 16:48 ` andris.pavenis at iki dot fi
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2012-09-09 11:50 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-09-09
     Ever Confirmed|0                           |1

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-09-09 11:50:18 UTC ---
(In reply to comment #0)
> Commenting out '#ifdef _GLIBCXX_USE_C99_STDINT_TR1' fixed build problem, but
> I'm not sure that it is correct solution.

It's not.

(In reply to comment #1)
> etc.  Those are the only uses of it in code that I can find.

It's used in many more headers.


>  It seems like it
> isn't exactly the best name for the define (it no longer just applies to TR1),
> but it doesn't do too much.  I can't think of a case where this would not be
> desired behavior (I don't remember, but I *think* that the C++ standard says
> that those typenames should be in the standard namespace).

But the C standard requires <stdint.h> and if the OS doesn't provide that we
can't provide a useful <cstdint>.

> Anyway, it doesn't appear like removing that code will have any adverse
> effects.

It would completely break libstdc++ on platforms without <stdint.h>, such as
djgpp

The fix is simply to check for the macro in random.cc

index 50b5359..1d0723d 100644
--- a/libstdc++-v3/src/c++11/random.cc
+++ b/libstdc++-v3/src/c++11/random.cc
@@ -24,6 +24,8 @@

 #include <random>

+#ifdef _GLIBCXX_USE_C99_STDINT_TR1
+
 #if defined __i386__ || defined __x86_64__
 # include <cpuid.h>
 #endif
@@ -142,5 +144,5 @@ namespace std _GLIBCXX_VISIBILITY(default)
     0xffffffffUL, 7,
     0x9d2c5680UL, 15,
     0xefc60000UL, 18, 1812433253UL>;
-
 }
+#endif


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

* [Bug libstdc++/54451] c++11/random.cc build failure when _GLIBCXX_USE_C99_STDINT_TR1 is not defined in config.h
  2012-09-01 12:01 [Bug libstdc++/54451] New: c++11/random.cc build failure when _GLIBCXX_USE_C99_STDINT_TR1 is not defined in config.h andris.pavenis at iki dot fi
                   ` (2 preceding siblings ...)
  2012-09-09 11:50 ` redi at gcc dot gnu.org
@ 2012-09-09 16:48 ` andris.pavenis at iki dot fi
  2012-09-09 17:20 ` redi at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: andris.pavenis at iki dot fi @ 2012-09-09 16:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Andris Pavenis <andris.pavenis at iki dot fi> 2012-09-09 16:47:44 UTC ---
My test was done with DJGPP development version (2.04) only. It has stdint.h,
but it was recognized by configure as unusable due to bug unrelated to GCC
itself. After fixing this problem locally libstdc++-v3 builds OK for DJGPP
v2.04 (only tested cross-native build from Linux)

Stable version DJGPP v2.03 does not have stdint.h

As the result I agree with the suggestion in comment 3 to completely disable
random.cc when _GLIBCXX_USE_C99_STDINT_TR1 is not defined

Maybe it would be nice to use #error in header file to inform the user that
this feature is not supported for target system (nicer than to get linker error
later)


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

* [Bug libstdc++/54451] c++11/random.cc build failure when _GLIBCXX_USE_C99_STDINT_TR1 is not defined in config.h
  2012-09-01 12:01 [Bug libstdc++/54451] New: c++11/random.cc build failure when _GLIBCXX_USE_C99_STDINT_TR1 is not defined in config.h andris.pavenis at iki dot fi
                   ` (3 preceding siblings ...)
  2012-09-09 16:48 ` andris.pavenis at iki dot fi
@ 2012-09-09 17:20 ` redi at gcc dot gnu.org
  2012-09-09 18:08 ` rbmj at verizon dot net
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2012-09-09 17:20 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-09-09 17:19:44 UTC ---
(In reply to comment #4)
> Maybe it would be nice to use #error in header file to inform the user that
> this feature is not supported for target system (nicer than to get linker error
> later)

You won't get a linker error, if the macro is not defined then the types in
<random> are not declared, so code using them won't compile.

Using #error would prevent #include <random> which I don't think is a good
idea. There's no harm including the header as long as you don't try to use
types which require a working <stdint.h>

The fix is to simply make random.cc check the macro. This is what we already do
in future.cc and thread.cc and mutex.cc and other files too.


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

* [Bug libstdc++/54451] c++11/random.cc build failure when _GLIBCXX_USE_C99_STDINT_TR1 is not defined in config.h
  2012-09-01 12:01 [Bug libstdc++/54451] New: c++11/random.cc build failure when _GLIBCXX_USE_C99_STDINT_TR1 is not defined in config.h andris.pavenis at iki dot fi
                   ` (4 preceding siblings ...)
  2012-09-09 17:20 ` redi at gcc dot gnu.org
@ 2012-09-09 18:08 ` rbmj at verizon dot net
  2012-09-09 18:19 ` redi at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rbmj at verizon dot net @ 2012-09-09 18:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from rbmj at verizon dot net 2012-09-09 18:08:11 UTC ---
Making local changes to bring stdint.h into compliance works for me as well.

(In reply to comment #5)
> (In reply to comment #4)
> > Maybe it would be nice to use #error in header file to inform the user that
> > this feature is not supported for target system (nicer than to get linker error
> > later)
> 
> You won't get a linker error, if the macro is not defined then the types in
> <random> are not declared, so code using them won't compile.

However, you will get weird "std::random_device" not declared errors, which
will seem strange to any end user.

> Using #error would prevent #include <random> which I don't think is a good
> idea. There's no harm including the header as long as you don't try to use
> types which require a working <stdint.h>

Agreed.  But could we use #warning to tell the user what's happening (if
portability is an issue we can check for __GNUC__) without going through the
source?

> The fix is to simply make random.cc check the macro. This is what we already do
> in future.cc and thread.cc and mutex.cc and other files too.

Also true.


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

* [Bug libstdc++/54451] c++11/random.cc build failure when _GLIBCXX_USE_C99_STDINT_TR1 is not defined in config.h
  2012-09-01 12:01 [Bug libstdc++/54451] New: c++11/random.cc build failure when _GLIBCXX_USE_C99_STDINT_TR1 is not defined in config.h andris.pavenis at iki dot fi
                   ` (5 preceding siblings ...)
  2012-09-09 18:08 ` rbmj at verizon dot net
@ 2012-09-09 18:19 ` redi at gcc dot gnu.org
  2012-09-14  9:45 ` paolo.carlini at oracle dot com
  2012-09-14 11:44 ` hjl.tools at gmail dot com
  8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2012-09-09 18:19 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-09-09 18:18:32 UTC ---
No, it should be consistent with how it's handled everywhere else.


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

* [Bug libstdc++/54451] c++11/random.cc build failure when _GLIBCXX_USE_C99_STDINT_TR1 is not defined in config.h
  2012-09-01 12:01 [Bug libstdc++/54451] New: c++11/random.cc build failure when _GLIBCXX_USE_C99_STDINT_TR1 is not defined in config.h andris.pavenis at iki dot fi
                   ` (6 preceding siblings ...)
  2012-09-09 18:19 ` redi at gcc dot gnu.org
@ 2012-09-14  9:45 ` paolo.carlini at oracle dot com
  2012-09-14 11:44 ` hjl.tools at gmail dot com
  8 siblings, 0 replies; 10+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-09-14  9:45 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hjl.tools at gmail dot com

--- Comment #8 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-09-14 09:44:23 UTC ---
*** Bug 54576 has been marked as a duplicate of this bug. ***


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

* [Bug libstdc++/54451] c++11/random.cc build failure when _GLIBCXX_USE_C99_STDINT_TR1 is not defined in config.h
  2012-09-01 12:01 [Bug libstdc++/54451] New: c++11/random.cc build failure when _GLIBCXX_USE_C99_STDINT_TR1 is not defined in config.h andris.pavenis at iki dot fi
                   ` (7 preceding siblings ...)
  2012-09-14  9:45 ` paolo.carlini at oracle dot com
@ 2012-09-14 11:44 ` hjl.tools at gmail dot com
  8 siblings, 0 replies; 10+ messages in thread
From: hjl.tools at gmail dot com @ 2012-09-14 11:44 UTC (permalink / raw)
  To: gcc-bugs

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

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.8.0

--- Comment #9 from H.J. Lu <hjl.tools at gmail dot com> 2012-09-14 11:44:20 UTC ---
Fixed by

http://gcc.gnu.org/ml/gcc-bugs/2012-09/msg01086.html


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

end of thread, other threads:[~2012-09-14 11:44 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-01 12:01 [Bug libstdc++/54451] New: c++11/random.cc build failure when _GLIBCXX_USE_C99_STDINT_TR1 is not defined in config.h andris.pavenis at iki dot fi
2012-09-09  2:36 ` [Bug libstdc++/54451] " rbmj at verizon dot net
2012-09-09 11:45 ` paolo.carlini at oracle dot com
2012-09-09 11:50 ` redi at gcc dot gnu.org
2012-09-09 16:48 ` andris.pavenis at iki dot fi
2012-09-09 17:20 ` redi at gcc dot gnu.org
2012-09-09 18:08 ` rbmj at verizon dot net
2012-09-09 18:19 ` redi at gcc dot gnu.org
2012-09-14  9:45 ` paolo.carlini at oracle dot com
2012-09-14 11:44 ` hjl.tools at gmail dot 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).