public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/67309] New: Error compiling with -std=c++11 and -fsingle-precision-constant
@ 2015-08-21 16:39 dflogeras2 at gmail dot com
  2015-08-21 18:26 ` [Bug libstdc++/67309] " redi at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: dflogeras2 at gmail dot com @ 2015-08-21 16:39 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67309

            Bug ID: 67309
           Summary: Error compiling with -std=c++11 and
                    -fsingle-precision-constant
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dflogeras2 at gmail dot com
  Target Milestone: ---

The ARM people recommend using -fsingle-precision-constant for targeting their
microcontrollers, such as the Cortex M4.  I am experimenting with using parts
of modern C++ on my uC projects.

If I compile the following (not just with arm cross compilers, even my native
linux compiler):

#include <algorithm>
int main() {}

with:
gcc test.cpp -fsingle-precision-constant -std=c++11 -c

It fails, since c++11 templating will not promote float types, and there is an
ambiguous 6.0 floating point constant in the bowels of the STL, which ends up
with a call to std::max<T>( float, double ) which is illegal.

Not sure what the proper fix is, and I'm also not sure why this used to compile
for me (same flags, gcc-4.7.3), but no longer does.


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

* [Bug libstdc++/67309] Error compiling with -std=c++11 and -fsingle-precision-constant
  2015-08-21 16:39 [Bug c++/67309] New: Error compiling with -std=c++11 and -fsingle-precision-constant dflogeras2 at gmail dot com
@ 2015-08-21 18:26 ` redi at gcc dot gnu.org
  2015-08-21 18:28 ` redi at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2015-08-21 18:26 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67309

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2015-08-21
          Component|c++                         |libstdc++
           Assignee|unassigned at gcc dot gnu.org      |redi at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Thanks for the nice testcase. There are a few such constants in the library,
and we *really* do want them to be double precision because we are passing them
to std::min<double> or std::max<double>, so they're meant to be doubles and so
-fsingle-precision-constant buys you nothing here. I suppose we can add an
explicit template argument list to the calls to force promotion to double.


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

* [Bug libstdc++/67309] Error compiling with -std=c++11 and -fsingle-precision-constant
  2015-08-21 16:39 [Bug c++/67309] New: Error compiling with -std=c++11 and -fsingle-precision-constant dflogeras2 at gmail dot com
  2015-08-21 18:26 ` [Bug libstdc++/67309] " redi at gcc dot gnu.org
@ 2015-08-21 18:28 ` redi at gcc dot gnu.org
  2015-08-21 19:58 ` dflogeras2 at gmail dot com
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2015-08-21 18:28 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67309

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
N.B. it fails for me even before GCC 4.7.3, possibly since <random> was first
added and included by <algorithm>.


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

* [Bug libstdc++/67309] Error compiling with -std=c++11 and -fsingle-precision-constant
  2015-08-21 16:39 [Bug c++/67309] New: Error compiling with -std=c++11 and -fsingle-precision-constant dflogeras2 at gmail dot com
  2015-08-21 18:26 ` [Bug libstdc++/67309] " redi at gcc dot gnu.org
  2015-08-21 18:28 ` redi at gcc dot gnu.org
@ 2015-08-21 19:58 ` dflogeras2 at gmail dot com
  2015-08-21 20:25 ` redi at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: dflogeras2 at gmail dot com @ 2015-08-21 19:58 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67309

--- Comment #3 from Dave Flogeras <dflogeras2 at gmail dot com> ---
That is what is weird to me, it definitely used to compile for me with GCC
4.7.3 and 4.8.3 (with the same build system flags).

Is there anything that is conditional when compiling GCC that maybe the Gentoo
crossdev folks have changed over time, which could mask this behaviour?  I
don't imagine they were patching those headers.  However, when I rebuild my
cross GCC 4.7.3 with crossdev, it now fails, as you've noted.

I am happy to test patchsets, and or even come up with them if you think this
is something worth delegating.  I have no experience in GCC's tree, but I can
follow orders :)


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

* [Bug libstdc++/67309] Error compiling with -std=c++11 and -fsingle-precision-constant
  2015-08-21 16:39 [Bug c++/67309] New: Error compiling with -std=c++11 and -fsingle-precision-constant dflogeras2 at gmail dot com
                   ` (2 preceding siblings ...)
  2015-08-21 19:58 ` dflogeras2 at gmail dot com
@ 2015-08-21 20:25 ` redi at gcc dot gnu.org
  2015-08-21 20:52 ` dflogeras2 at gmail dot com
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2015-08-21 20:25 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67309

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Are you site you were always using -std=c++11?

The algorithm header won't include the random header without that.


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

* [Bug libstdc++/67309] Error compiling with -std=c++11 and -fsingle-precision-constant
  2015-08-21 16:39 [Bug c++/67309] New: Error compiling with -std=c++11 and -fsingle-precision-constant dflogeras2 at gmail dot com
                   ` (3 preceding siblings ...)
  2015-08-21 20:25 ` redi at gcc dot gnu.org
@ 2015-08-21 20:52 ` dflogeras2 at gmail dot com
  2015-08-21 21:07 ` dflogeras2 at gmail dot com
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: dflogeras2 at gmail dot com @ 2015-08-21 20:52 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67309

--- Comment #5 from Dave Flogeras <dflogeras2 at gmail dot com> ---
Definitely, this project is my testbed for playing with new C++ features on a
STM32F4 micro.  I also checked the ChibiOS (the RTOS I use) and it has always
had -fsingle-precision-constant defined (well for all versions I have used in
the past year).

Certainly mysterious, maybe Gentoo was patching it.. I mean it has to be
deterministic after all.


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

* [Bug libstdc++/67309] Error compiling with -std=c++11 and -fsingle-precision-constant
  2015-08-21 16:39 [Bug c++/67309] New: Error compiling with -std=c++11 and -fsingle-precision-constant dflogeras2 at gmail dot com
                   ` (4 preceding siblings ...)
  2015-08-21 20:52 ` dflogeras2 at gmail dot com
@ 2015-08-21 21:07 ` dflogeras2 at gmail dot com
  2015-08-24 13:44 ` redi at gcc dot gnu.org
  2015-08-24 13:49 ` redi at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: dflogeras2 at gmail dot com @ 2015-08-21 21:07 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67309

--- Comment #6 from Dave Flogeras <dflogeras2 at gmail dot com> ---
Created attachment 36237
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36237&action=edit
Patch for random.tcc

This patch made the test case presented compile cleanly for myself.  It is from
GCC-4.8.4's tree because that is what I had kicking around.


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

* [Bug libstdc++/67309] Error compiling with -std=c++11 and -fsingle-precision-constant
  2015-08-21 16:39 [Bug c++/67309] New: Error compiling with -std=c++11 and -fsingle-precision-constant dflogeras2 at gmail dot com
                   ` (5 preceding siblings ...)
  2015-08-21 21:07 ` dflogeras2 at gmail dot com
@ 2015-08-24 13:44 ` redi at gcc dot gnu.org
  2015-08-24 13:49 ` redi at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2015-08-24 13:44 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67309

--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Author: redi
Date: Mon Aug 24 13:43:36 2015
New Revision: 227126

URL: https://gcc.gnu.org/viewcvs?rev=227126&root=gcc&view=rev
Log:
        PR libstdc++/67309
        * include/bits/random.tcc
        (poisson_distribution::param_type::_M_initialize): Use max<double>.
        (binomial_distribution::param_type::_M_initialize): Likewise.
        * testsuite/17_intro/headers/c++200x/67309.cc: New.
        * testsuite/17_intro/headers/c++200x/all_attributes.cc: Remove
        redundant header.

Added:
    trunk/libstdc++-v3/testsuite/17_intro/headers/c++200x/67309.cc
      - copied, changed from r227110,
trunk/libstdc++-v3/testsuite/17_intro/headers/c++200x/all_attributes.cc
Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/bits/random.tcc
    trunk/libstdc++-v3/testsuite/17_intro/headers/c++200x/all_attributes.cc


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

* [Bug libstdc++/67309] Error compiling with -std=c++11 and -fsingle-precision-constant
  2015-08-21 16:39 [Bug c++/67309] New: Error compiling with -std=c++11 and -fsingle-precision-constant dflogeras2 at gmail dot com
                   ` (6 preceding siblings ...)
  2015-08-24 13:44 ` redi at gcc dot gnu.org
@ 2015-08-24 13:49 ` redi at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2015-08-24 13:49 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67309

--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed on trunk.


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

end of thread, other threads:[~2015-08-24 13:49 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-21 16:39 [Bug c++/67309] New: Error compiling with -std=c++11 and -fsingle-precision-constant dflogeras2 at gmail dot com
2015-08-21 18:26 ` [Bug libstdc++/67309] " redi at gcc dot gnu.org
2015-08-21 18:28 ` redi at gcc dot gnu.org
2015-08-21 19:58 ` dflogeras2 at gmail dot com
2015-08-21 20:25 ` redi at gcc dot gnu.org
2015-08-21 20:52 ` dflogeras2 at gmail dot com
2015-08-21 21:07 ` dflogeras2 at gmail dot com
2015-08-24 13:44 ` redi at gcc dot gnu.org
2015-08-24 13:49 ` redi at gcc dot gnu.org

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).