Re: [cfe-users] Compiling C++ 20 Example from 24.6.4.1 [range.istream.overview] produces errors with libstdc++ 10

2020-05-26 Thread Ray Lischner via cfe-users

On 5/15/20 6:53 PM, Richard Smith wrote:
Can you try calling begin() on an istream_view& directly, and see 
if you get the same error?


$ cat istream_begin.cpp
#include 
#include 
#include 
#include 

int main()
{
  auto ints = std::istringstream{"0 1 2 3 4"};
  auto view{ std::ranges::istream_view(ints) };
  auto begin{ std::ranges::begin(view) };
  assert(&*view.begin() == &*begin);
}
$ g++ -std=c++20 istream_begin.cpp
$ ./a.out
$ clang++ -std=c++20 istream_begin.cpp
In file included from istream_begin.cpp:2:
In file included from 
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/iostream:39:
In file included from 
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/ostream:38:
In file included from 
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/ios:40:
In file included from 
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/char_traits.h:39:
In file included from 
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/stl_algobase.h:65:
In file included from 
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/stl_iterator_base_types.h:71:
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:902:13: 
error: no matching function for call to '__ranges_begin'

= decltype(__detail::__ranges_begin(std::declval<_Tp&>()));
   ^~~~
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/range_access.h:874:5: 
note: in instantiation of template type alias '__range_iter_t' requested 
here

using iterator_t = std::__detail::__range_iter_t<_Tp>;
^
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/ranges:134:43: 
note: in instantiation of template type alias 'iterator_t' requested here

  data() requires contiguous_iterator>
  ^
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/ranges:956:14: 
note: in instantiation of template class 
'std::ranges::view_interfacestd::char_traits > >' requested here

: public view_interface>
 ^
istream_begin.cpp:9:14: note: in instantiation of template class 
'std::ranges::basic_istream_view >' 
requested here

  auto view{ std::ranges::istream_view(ints) };
 ^
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:885:7: 
note: candidate template ignored: constraints not satisfied [with _Tp = 
std::ranges::basic_istream_view >]

  __ranges_begin(_Tp& __t)
  ^
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:883:16: 
note: because 'is_array_vstd::char_traits > >' evaluated to false

  requires is_array_v<_Tp> || __member_begin<_Tp&> || __adl_begin<_Tp&>
   ^
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:883:35: 
note: and 'std::ranges::basic_istream_viewstd::char_traits > &' does not satisfy '__member_begin'

  requires is_array_v<_Tp> || __member_begin<_Tp&> || __adl_begin<_Tp&>
  ^
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:867:33: 
note: because '__detail::__decay_copy(__t.begin())' would be invalid: no 
member named 'begin' in 'std::ranges::basic_istream_viewstd::char_traits >'
  { __detail::__decay_copy(__t.begin()) } -> 
input_or_output_iterator;

   ^
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:883:59: 
note: and 'std::ranges::basic_istream_viewstd::char_traits > &' does not satisfy '__adl_begin'

  requires is_array_v<_Tp> || __member_begin<_Tp&> || __adl_begin<_Tp&>
  ^
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:877:29: 
note: because '__detail::__decay_copy(begin(__t))' would be invalid: 
call to deleted function 'begin'
  { __detail::__decay_copy(begin(__t)) } -> 
input_or_output_iterator;

   ^
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:902:13: 
error: no matching function for call to '__ranges_begin'

= decltype(__detail::__ranges_begin(std::declval<_Tp&>()));
   ^~~~
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/range_access.h:874:5: 
note: in instantiation of template type alias '__range_iter_t' requested 
here

using iterator_t = std::__detail::__range_iter_t<_Tp>;
^
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/ranges:140:25: 
note: in instantiation of template type alias 'iterator_t' requested here

&& contiguous_iterator>
   ^
/usr/bin/../l

Re: [cfe-users] Compiling C++ 20 Example from 24.6.4.1 [range.istream.overview] produces errors with libstdc++ 10

2020-05-26 Thread Richard Smith via cfe-users
On Tue, 26 May 2020 at 07:39, Ray Lischner via cfe-users <
cfe-users@lists.llvm.org> wrote:

> On 5/15/20 6:53 PM, Richard Smith wrote:
> > Can you try calling begin() on an istream_view& directly, and see
> > if you get the same error?
>
> $ cat istream_begin.cpp
> #include 
> #include 
> #include 
> #include 
>
> int main()
> {
>auto ints = std::istringstream{"0 1 2 3 4"};
>auto view{ std::ranges::istream_view(ints) };
>auto begin{ std::ranges::begin(view) };
>

Here, Clang claims istream_view has no member named 'begin', during
satisfaction checking.


>assert(&*view.begin() == &*begin);
>

... but Clang accepts this. There's definitely something wrong here.

Can you humor me for a second and try calling 'view.begin()' directly
before using std::ranges::begin? (I'm suspicious that we're somehow not
triggering instantiation of istream_view until too late; calling
'view.begin()' earlier would resolve the problem if that's the case.)


> }
> $ g++ -std=c++20 istream_begin.cpp
> $ ./a.out
> $ clang++ -std=c++20 istream_begin.cpp
> In file included from istream_begin.cpp:2:
> In file included from
>
> /usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/iostream:39:
> In file included from
>
> /usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/ostream:38:
> In file included from
>
> /usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/ios:40:
> In file included from
>
> /usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/char_traits.h:39:
> In file included from
>
> /usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/stl_algobase.h:65:
> In file included from
>
> /usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/stl_iterator_base_types.h:71:
> /usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:902:13:
>
> error: no matching function for call to '__ranges_begin'
>  = decltype(__detail::__ranges_begin(std::declval<_Tp&>()));
> ^~~~
> /usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/range_access.h:874:5:
>
> note: in instantiation of template type alias '__range_iter_t' requested
> here
>  using iterator_t = std::__detail::__range_iter_t<_Tp>;
>  ^
> /usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/ranges:134:43:
>
> note: in instantiation of template type alias 'iterator_t' requested here
>data() requires contiguous_iterator>
>^
> /usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/ranges:956:14:
>
> note: in instantiation of template class
> 'std::ranges::view_interface std::char_traits > >' requested here
>  : public view_interface>
>   ^
> istream_begin.cpp:9:14: note: in instantiation of template class
> 'std::ranges::basic_istream_view >'
> requested here
>auto view{ std::ranges::istream_view(ints) };
>   ^
> /usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:885:7:
>
> note: candidate template ignored: constraints not satisfied [with _Tp =
> std::ranges::basic_istream_view >]
>__ranges_begin(_Tp& __t)
>^
> /usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:883:16:
>
> note: because 'is_array_v std::char_traits > >' evaluated to false
>requires is_array_v<_Tp> || __member_begin<_Tp&> ||
> __adl_begin<_Tp&>
> ^
> /usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:883:35:
>
> note: and 'std::ranges::basic_istream_view std::char_traits > &' does not satisfy '__member_begin'
>requires is_array_v<_Tp> || __member_begin<_Tp&> ||
> __adl_begin<_Tp&>
>^
> /usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:867:33:
>
> note: because '__detail::__decay_copy(__t.begin())' would be invalid: no
> member named 'begin' in 'std::ranges::basic_istream_view std::char_traits >'
>{ __detail::__decay_copy(__t.begin()) } ->
> input_or_output_iterator;
> ^
> /usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:883:59:
>
> note: and 'std::ranges::basic_istream_view std::char_traits > &' does not satisfy '__adl_begin'
>requires is_array_v<_Tp> || __member_begin<_Tp&> ||
> __adl_begin<_Tp&>
>^
> /usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:877:29:
>
> note: because '__detail::__decay_copy(begin(__t))' would be invalid:
> call to deleted function 'begin'
>{ __detail::__decay_copy(begin(__t)) } ->
> input_or_output_iterator;
> ^
> /usr/bin/..

Re: [cfe-users] _Decimal128 on PowerPC

2020-05-26 Thread Richard Smith via cfe-users
On Fri, 8 May 2020 at 00:09, Jeffrey Walton via cfe-users <
cfe-users@lists.llvm.org> wrote:

> Hi Everyone,
>
> I'm testing Steven Munroe's pveclib library
> (https://github.com/munroesj52/pveclib). It is testing OK with GCC,
> but I am having trouble with Clang.
>
> I've been able to test up to Clang 9 and with/without -std=c11, but I
> keep encountering two errors:
>
> decpowof2.c:30:7: error: GNU decimal type extension not supported
> const _Decimal128 decpowof2 [] = {
>
> decpowof2.c:31:8: error: invalid suffix 'DL' on floating constant
> 1.0E+0DL,   /* 2**0 */
>
> I believe _Decimal128 and the DL suffixes are part of ISO/IEC TS 18661
> or N2341 (http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2341.pdf).
>

Clang does not implement ISO/IEC TS 18661-2 (decimal floating point).

It seems like a bug that our diagnostic claims this is a GNU extension,
since it's an ISO Technical Specification, but otherwise the diagnostic is
accurate. =(

We'd accept patches if you felt motivated to contribute an implementation,
but a high-quality implementation would likely be a fair amount of work
(LLVM has no support for decimal floating-point types yet).

I think I am missing the right combination of Clang compiler and options.
>
> What compiler or options are needed for Clang?
> ___
> cfe-users mailing list
> cfe-users@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users
>
___
cfe-users mailing list
cfe-users@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users


Re: [cfe-users] Location of function name?

2020-05-26 Thread Richard Smith via cfe-users
On Fri, 22 May 2020 at 19:06, Sterling B via cfe-users <
cfe-users@lists.llvm.org> wrote:

> Hi Clang Experts, could you kindly advice how to get location of a
> function *name* when visiting FunctionDecl in RecursiveASTVisitor
> (getBeginLoc and getEndLoc return the whole range for the definition, not
> just the name). Example:
>
> For source code like this:
> int f(int x) { return x + 1; }
>
> this is the current code
>
> bool VisitFunctionDecl(clang::FunctionDecl *FD) {
> clang::ASTContext &context = FD->getASTContext();
> int begin = context.getFullLoc(FD->getBeginLoc()).getFileOffset();
> int end = context.getFullLoc(FD->getEndLoc()).getFileOffset();
> std::string path =
> context.getFullLoc(FD->getBeginLoc()).getFileEntry()->getName().str();
> .   ..
> }
>
> will give offsets [0,29], but I'd like to get the location of the "f",
> i.e. [5-6].
>

In general, you can use getLocation() to get the location of the name in a
NamedDecl. For a FunctionDecl, there's also getNameInfo(), which will
return more detailed information about the name of the function (allowing
you to handle the case where the function name is more than a single token,
such as for C++ functions with non-identifier names like "operator int*").
If you want to also include the preceding C++ nested name specifier as part
of the name, you can use getQualifierLoc to determine its location.


> Thanks!
> Sterling.
> ___
> cfe-users mailing list
> cfe-users@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users
>
___
cfe-users mailing list
cfe-users@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users


Re: [cfe-users] Compiling C++ 20 Example from 24.6.4.1 [range.istream.overview] produces errors with libstdc++ 10

2020-05-26 Thread Ray Lischner via cfe-users

On 5/26/20 2:57 PM, Richard Smith wrote:

Can you humor me for a second and try calling 'view.begin()' directly 
before using std::ranges::begin? (I'm suspicious that we're somehow not 
triggering instantiation of istream_view until too late; calling 
'view.begin()' earlier would resolve the problem if that's the case.)

$ cat istream_begin.cpp
#include 
#include 
#include 
#include 

int main()
{
  auto ints = std::istringstream{"0 1 2 3 4"};
  auto view{ std::ranges::istream_view(ints) };
  auto view_begin{ view.begin() };
  auto begin{ std::ranges::begin(view) };
  assert(&*view_begin == &*begin);
}
$ clang++ -std=c++20 istream_begin.cpp
In file included from istream_begin.cpp:2:
In file included from 
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/iostream:39:
In file included from 
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/ostream:38:
In file included from 
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/ios:40:
In file included from 
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/char_traits.h:39:
In file included from 
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/stl_algobase.h:65:
In file included from 
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/stl_iterator_base_types.h:71:
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:902:13: 
error: no matching function for call to '__ranges_begin'

= decltype(__detail::__ranges_begin(std::declval<_Tp&>()));
   ^~~~
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/range_access.h:874:5: 
note: in instantiation of template type alias '__range_iter_t' requested 
here

using iterator_t = std::__detail::__range_iter_t<_Tp>;
^
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/ranges:134:43: 
note: in instantiation of template type alias 'iterator_t' requested here

  data() requires contiguous_iterator>
  ^
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/ranges:956:14: 
note: in instantiation of template class 
'std::ranges::view_interfacestd::char_traits > >' requested here

: public view_interface>
 ^
istream_begin.cpp:9:14: note: in instantiation of template class 
'std::ranges::basic_istream_view >' 
requested here

  auto view{ std::ranges::istream_view(ints) };
 ^
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:885:7: 
note: candidate template ignored: constraints not satisfied [with _Tp = 
std::ranges::basic_istream_view >]

  __ranges_begin(_Tp& __t)
  ^
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:883:16: 
note: because 'is_array_vstd::char_traits > >' evaluated to false

  requires is_array_v<_Tp> || __member_begin<_Tp&> || __adl_begin<_Tp&>
   ^
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:883:35: 
note: and 'std::ranges::basic_istream_viewstd::char_traits > &' does not satisfy '__member_begin'

  requires is_array_v<_Tp> || __member_begin<_Tp&> || __adl_begin<_Tp&>
  ^
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:867:33: 
note: because '__detail::__decay_copy(__t.begin())' would be invalid: no 
member named 'begin' in 'std::ranges::basic_istream_viewstd::char_traits >'
  { __detail::__decay_copy(__t.begin()) } -> 
input_or_output_iterator;

   ^
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:883:59: 
note: and 'std::ranges::basic_istream_viewstd::char_traits > &' does not satisfy '__adl_begin'

  requires is_array_v<_Tp> || __member_begin<_Tp&> || __adl_begin<_Tp&>
  ^
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:877:29: 
note: because '__detail::__decay_copy(begin(__t))' would be invalid: 
call to deleted function 'begin'
  { __detail::__decay_copy(begin(__t)) } -> 
input_or_output_iterator;

   ^
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:902:13: 
error: no matching function for call to '__ranges_begin'

= decltype(__detail::__ranges_begin(std::declval<_Tp&>()));
   ^~~~
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/range_access.h:874:5: 
note: in instantiation of template type alias '__range_iter_t' requested 
here

using iterator_t = std::__detail::__range_iter_t<_Tp>;
^
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c+

[cfe-users] Are these bugs for the clang compilers?

2020-05-26 Thread Tianyou via cfe-users
Hello everyone,

I found some questionable behaviors in the clang compiler.

I tried to calculate the smallest number in my machine with clang. I did it by 
looping as: 

a = a / 1.73

In g++, after 1358 loops, I found that a = 4.94066E-324, and the value of a 
never changes from loop 1358 till the end 1500 loop.

It is questionable for me that a non zero real number here a = 4.94066E-324 
divided by a non zero and non one real number here 1.73 will keep the same 
value. The phenomenon seems to the qualification of the ground state energy in 
a quantum system.

Is this bug for the clang compiler?

I tested my code with, g++ (Apple LLVM version 10.0.0, clang-1000.10.44.4) on 
Macintosh. I also tried a = a / 1.7, a = a / 1.77. 

All have similar results. A ground state qualification and unchanged value of 
a. 

I guess that it is related to the binary system used by the computer 
system. 

Here with my codes. 



Best wishes
Tianyou Yi
Postdoc researcher in National Tsing Hua University



Best wishes
Tianyou Yi 

Please send me to 
yitianyo...@qq.com
yitianyou9...@gzemail.cn




 

 ___
cfe-users mailing list
cfe-users@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users