This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C++ PATCH for c++/49673 (constexpr init should go in rodata)


On Fri, Jul 08, 2011 at 10:22:16AM -0400, Jason Merrill wrote:
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-rom.C
> @@ -0,0 +1,11 @@
> +// PR c++/49673: check that test_data goes into .rodata
> +// { dg-options -std=c++0x }
> +// { dg-final { scan-assembler "rodata" } }

That will match only on ELF and perhaps a few other targets, but I'm certain
many targets put read-only data elsewhere.  I'd just guard this
with a few most common target triplets that are known to use .rodata
section.

> +
> +struct Data
> +{
> +  int i;
> +  constexpr Data(int i = 0) : i(i+1) {}
> +};
> +
> +extern const Data test_data = { 1 };

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]