Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FYI gcc warns of 'const qualifier ignored on return type' #1

Open
willwray opened this issue May 5, 2018 · 3 comments
Open

FYI gcc warns of 'const qualifier ignored on return type' #1

willwray opened this issue May 5, 2018 · 3 comments

Comments

@willwray
Copy link

willwray commented May 5, 2018

https://wandbox.org/permlink/EjDDKW72cTOKB3et
^^^ cut n paste the span snippet to wandbox with recent gcc gives vvv

4x warning: type qualifiers ignored on function return type on cbegin() and cend()
(and a couple of signed/unsigned comparison warning in the test code)

I managed to quieten the warnings by

  • adding a const_pointer typedef with const added to the type
  • updating const_iterator typedef from const pointer to const_pointer
    (or, just update const_iterator but I prefer to also have a const_pointer typedef).
    using const_pointer  = _Tp const*;     // added
    using const_iterator = const_pointer;  // updated
@mclow
Copy link
Owner

mclow commented May 7, 2018

Thanks for the report - we're going to be looking at bugs in <span> in Rapperswil next month. I'll make sure that this gets discussed (and probably updated in the standard).

@mclow
Copy link
Owner

mclow commented May 7, 2018

And I'll make sure that those warnings are squashed before I land this in libc++

@willwray
Copy link
Author

willwray commented May 7, 2018

Thanks for posting these snippets - I'd studied the earlier array_view snippet too.

The same bug was lying latent in my code - without warning - so it's useful that gcc flushed it out here. Clang doesn't warn (with the same flags). Coincidentally, on cpplang slack #general today arthur-odwyer found this same const pointer bug in some other multidimensional array code. Maybe there's a common ancestor. Can't remember if I'd copied or concocted-it-up.

It does sound like a storm is brewing over span's cbegin return:
Again on slack today, in #future_standard, a >100 thread was sparked by tvaneerd's "irregular span" paper, which itself references 'a giant reflector discussion', with caseycarter noting: I think it's an abomination that cbegin(span) and span.cbegin() have different meaning

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants