Re: Invalid use of 'void'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 19 May 2020 at 12:07, Florian Weimer <fweimer@xxxxxxxxxx> wrote:
>
> * Jonathan Wakely via Gcc-help:
>
> > And G++ does allow arithmetic involving a void* and an integer, e.g.
> > p1 - 32 or p2 + 64, it doesn't allow subtracting one void* from the
> > other. So the extension is only partially supported for C++. We should
> > probably document that.
>
> And it's a regression, GCC 2.7.2.3 can compile it, but GCC 2.95.2
> cannot.  (Of course, I'm only half-serious here.)
>
> The problem I see with such extensions in C++ is that they could alter
> SFINAE outcomes.  But maybe that's less important these days because
> people don't write custom type traits anymore.

Most such extensions are disabled in SFINAE contexts:

template<typename T>
auto f(T* p) -> decltype(p+1) { return p + 1; }

int main()
{
  void* p = nullptr;
  p = p + 1;  // warning
  f(p); // error
}



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux