David Brown <
david...@hesbynett.no> writes:
> On 06/10/17 09:31, Christian Gollwitzer wrote:
>> Am 06.10.17 um 08:48 schrieb David Brown:
>>> On 06/10/17 08:37, Christian Gollwitzer wrote:
<snip>
>>>>
https://www.youtube.com/watch?v=4AfRAVcThyA
<snip>
>>> ... I greatly prefer to /read/ stuff - varying the speed to match
>>> my interest as I go.)
Me too. Video seems to me to a dreadful way to convey technical
information. It makes sense to have conferences about things, but the
old way was always to have published proceedings.
<snip>
>> I couldn't find a paper-like write-up for the talk.
There's this:
https://herbsutter.files.wordpress.com/2017/07/p0707r1.pdf
but it's not about the talk. It's a detailed technical description of
the proposal (presumably and early version).
<snip>
>> I haven't been following it too closely, but for instance such a beast:
>>
>>
https://codereview.stackexchange.com/questions/133668/constexpr-sin-function-c-14
>>
>> drives me away. Do I really need to build my own sine function to be
>> able to use it in a constexpr? In order to get a trigonometric lookup
>> table currently I'm using a different language to generate C++ code,
>> which is of course not satisfying.
>
> No, you don't need your own sine function - it seems to be fine to use
> std::sin in constexpr functions. (I use the phrase "seems to be fine",
> because it works in practice when I tested it, but I am not sure if the
> standards guarantee it is correct.)
clang says no and gcc says yes. These are all with -std=c++14 and
-pedantic (plus warning flags) to try to get standard conformance
without extensions.
clang says (of your example)
constexpr double const_sine(double x) {
^
t.cc:6:12: note: non-constexpr function 'sin' cannot be used in a constant
expression
return std::sin(x);
^
> Here is an example - it generates a
> sine table with int16_t entries, such as one might want in a small
> embedded system:
>
> #include <stdint.h>
> #include <cmath>
>
> constexpr double const_sine(double x) {
> return std::sin(x);
> }
>
> const auto pi = 3.14159265358979323846264338327;
> const auto pi2 = 2 * pi;
gcc wants these to be constexpr -- my gcc version (5.4.0) won't compile
the example without it -- but clang is not bothered. I wonder what's up
here. Neither gcc not clang compiled the example without change but for
different reasons. Am I missing some option?
(gcc also objects to size_t not being defined. I never know what
headers are obliged to define size_t and which ones are not, but I added
cstddef to be sure.)
<snip>
--
Ben.