Bug 64367 - [5 Regression] g++-v5/stdexcept:52:28: error: invalid use of non-static data member '_M_p'
Summary: [5 Regression] g++-v5/stdexcept:52:28: error: invalid use of non-static data ...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 5.0
: P3 normal
Target Milestone: 5.0
Assignee: Jonathan Wakely
URL:
Keywords:
: 65399 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-12-20 11:43 UTC by Markus Trippelsdorf
Modified: 2015-03-12 12:57 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2015-02-26 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Trippelsdorf 2014-12-20 11:43:27 UTC
Since r218964 clang complains, e.g.:

markus@x4 ~ % clang++ -Ofast -w tramp3d-v4.cpp
In file included from tramp3d-v4.cpp:7:
In file included from /usr/lib64/gcc/x86_64-pc-linux-gnu/5.0.0/include/g++-v5/complex:45:
In file included from /usr/lib64/gcc/x86_64-pc-linux-gnu/5.0.0/include/g++-v5/sstream:38:
In file included from /usr/lib64/gcc/x86_64-pc-linux-gnu/5.0.0/include/g++-v5/istream:38:
In file included from /usr/lib64/gcc/x86_64-pc-linux-gnu/5.0.0/include/g++-v5/ios:42:
In file included from /usr/lib64/gcc/x86_64-pc-linux-gnu/5.0.0/include/g++-v5/bits/ios_base.h:44:
/usr/lib64/gcc/x86_64-pc-linux-gnu/5.0.0/include/g++-v5/stdexcept:52:28: error: invalid use of non-static data member '_M_p'
      char _M_bytes[sizeof(_M_p)];
                           ^~~~
1 error generated.
Comment 1 Jonathan Wakely 2014-12-20 13:01:58 UTC
I don't know why clang complains, it accepts this, which shouldn't be any different:

  char _M_bytes[sizeof(decltype(_M_p))];
Comment 2 Markus Trippelsdorf 2014-12-20 13:31:19 UTC
It doesn't accept your example for C++98, too. C++11 is fine.

markus@x4 ~ % cat test.ii
union u
{
  const char *_M_p;
  char _M_bytes[sizeof (_M_p)];
};

markus@x4 ~ % clang++ -std=c++11 -O2 -c test.ii
markus@x4 ~ % clang++ -O2 -c test.ii
test.ii:4:25: error: invalid use of non-static data member '_M_p'
  char _M_bytes[sizeof (_M_p)];
                        ^~~~
1 error generated.
markus@x4 ~ % 

This looks correct to me.
Comment 3 Markus Trippelsdorf 2014-12-20 14:01:57 UTC
See § 5.1.1-13 for C++11 and § 5.1-10 for C++98.
The C++98 standard doesn't mention unevaluated operands.
Comment 4 Jonathan Wakely 2014-12-20 14:23:32 UTC
Oh it's only for 98, I see.

Well it's easy to fix with sizeof(const char*) anyway.
Comment 5 Jonathan Wakely 2014-12-21 15:16:41 UTC
Author: redi
Date: Sun Dec 21 15:16:08 2014
New Revision: 218997

URL: https://gcc.gnu.org/viewcvs?rev=218997&root=gcc&view=rev
Log:
	PR libstdc++/64367
	* include/std/stdexcept: Don't use non-static member in sizeof.

Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/std/stdexcept
Comment 6 Jonathan Wakely 2014-12-21 15:17:44 UTC
should be fixed
Comment 7 Jonathan Wakely 2015-02-26 16:33:09 UTC
There's another instance of the same error later in the file:

/../lib/gcc/x86_64-redhat-linux/5.0.0/../../../../include/c++/5.0.0/stdexcept:83:28: error: invalid use of non-static data member '_M_s'
      char _M_bytes[sizeof(_M_s)];
                           ^~~~
Comment 8 Jonathan Wakely 2015-03-02 16:50:56 UTC
Author: redi
Date: Mon Mar  2 16:50:24 2015
New Revision: 221118

URL: https://gcc.gnu.org/viewcvs?rev=221118&root=gcc&view=rev
Log:
	PR libstdc++/64367
	* include/std/stdexcept (__sso_string): Don't use non-static member
	in sizeof.

Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/std/stdexcept
Comment 9 Jonathan Wakely 2015-03-02 16:51:58 UTC
Should really be fixed this time.
Comment 10 Jonathan Wakely 2015-03-12 12:57:31 UTC
*** Bug 65399 has been marked as a duplicate of this bug. ***