public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, testsuite] Fix usage of sizeof in testsuite/g++.dg/cpp0x/rv[1..8]p.C
@ 2010-08-13  7:26 Uros Bizjak
  2010-08-13 20:56 ` Ian Lance Taylor
  0 siblings, 1 reply; 3+ messages in thread
From: Uros Bizjak @ 2010-08-13  7:26 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1364 bytes --]

On Fri, Aug 13, 2010 at 6:15 AM, Ian Lance Taylor <iant@google.com> wrote:

>> A problem arises with the code in testsuite/g++.dg/cpp0x/rv[1..8]p.C.
>> These tests use "sizeof(..character array...) == <n>", but sizeof char
>> array depends heavily on the value of #define STRUCTURE_SIZE_BOUNDARY.
>> Targets that define this value to i.e. 32 (for performance reasons,
>> instead of default BITS_PER_UNIT) will fail all these checks.
>>
>> Would it be acceptable to change all these checks from
>>
>>     "sa<sizeof(foo(a)) == 1> t1;"
>>
>> to
>>
>>     "sa<sizeof(foo(a)) != 0> t1;" ?
>
> Sounds fine to me.

Attached is the mechanical patch that implements proposed change.

2010-08-13  Uros Bizjak  <ubizjak@gmail.com>

	* g++.dg/cast.C: Change "sizeof(...) = <n>" checks
	to "sizeof(...) != 0" to pass on targets with
	STRUCTURE_SIZE_BOUNDARY != BITS_PER_UNIT.
	* g++.dg/cpp0x/iop.C: Ditto.
	* g++.dg/cpp0x/named_refs.C: Ditto.
	* g++.dg/cpp0x/rv1p.C: Ditto.
	* g++.dg/cpp0x/rv2p.C: Ditto.
	* g++.dg/cpp0x/rv3p.C: Ditto.
	* g++.dg/cpp0x/rv4p.C: Ditto.
	* g++.dg/cpp0x/rv5p.C: Ditto.
	* g++.dg/cpp0x/rv6p.C: Ditto.
	* g++.dg/cpp0x/rv7p.C: Ditto.
	* g++.dg/cpp0x/rv8p.C: Ditto.
	* g++.dg/cpp0x/unnamed_refs.C: Ditto.

Tested on x86_64-pc-linux-gnu {,-m32} and my private target.

OK for 4.4, 4.5 and SVN mainline?

Uros.

[-- Attachment #2: t.diff.txt.bz2 --]
[-- Type: application/x-bzip2, Size: 7946 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH, testsuite] Fix usage of sizeof in testsuite/g++.dg/cpp0x/rv[1..8]p.C
  2010-08-13  7:26 [PATCH, testsuite] Fix usage of sizeof in testsuite/g++.dg/cpp0x/rv[1..8]p.C Uros Bizjak
@ 2010-08-13 20:56 ` Ian Lance Taylor
  2010-08-14 12:37   ` Uros Bizjak
  0 siblings, 1 reply; 3+ messages in thread
From: Ian Lance Taylor @ 2010-08-13 20:56 UTC (permalink / raw)
  To: Uros Bizjak; +Cc: gcc-patches

Uros Bizjak <ubizjak@gmail.com> writes:

> On Fri, Aug 13, 2010 at 6:15 AM, Ian Lance Taylor <iant@google.com> wrote:
>
>>> A problem arises with the code in testsuite/g++.dg/cpp0x/rv[1..8]p.C.
>>> These tests use "sizeof(..character array...) == <n>", but sizeof char
>>> array depends heavily on the value of #define STRUCTURE_SIZE_BOUNDARY.
>>> Targets that define this value to i.e. 32 (for performance reasons,
>>> instead of default BITS_PER_UNIT) will fail all these checks.
>>>
>>> Would it be acceptable to change all these checks from
>>>
>>>     "sa<sizeof(foo(a)) == 1> t1;"
>>>
>>> to
>>>
>>>     "sa<sizeof(foo(a)) != 0> t1;" ?
>>
>> Sounds fine to me.
>
> Attached is the mechanical patch that implements proposed change.
>
> 2010-08-13  Uros Bizjak  <ubizjak@gmail.com>
>
> 	* g++.dg/cast.C: Change "sizeof(...) = <n>" checks
> 	to "sizeof(...) != 0" to pass on targets with
> 	STRUCTURE_SIZE_BOUNDARY != BITS_PER_UNIT.
> 	* g++.dg/cpp0x/iop.C: Ditto.
> 	* g++.dg/cpp0x/named_refs.C: Ditto.
> 	* g++.dg/cpp0x/rv1p.C: Ditto.
> 	* g++.dg/cpp0x/rv2p.C: Ditto.
> 	* g++.dg/cpp0x/rv3p.C: Ditto.
> 	* g++.dg/cpp0x/rv4p.C: Ditto.
> 	* g++.dg/cpp0x/rv5p.C: Ditto.
> 	* g++.dg/cpp0x/rv6p.C: Ditto.
> 	* g++.dg/cpp0x/rv7p.C: Ditto.
> 	* g++.dg/cpp0x/rv8p.C: Ditto.
> 	* g++.dg/cpp0x/unnamed_refs.C: Ditto.
>
> Tested on x86_64-pc-linux-gnu {,-m32} and my private target.
>
> OK for 4.4, 4.5 and SVN mainline?

Hmmm, actually, looking at the patch, I'm not sure this is the best
approach.  The problem is that your patch means that some of the tests
no longer actually test anything.  E.g., in rv2p.C, we have this:

    sa<sizeof(sink_2_13(a))           == 1> t1;
    sa<sizeof(sink_2_13(va))          == 3> t3;

The point of this test is to check function overloading.  Change both
instances to != 0 means that the test is no longer testing anything.

So a better approach here is going to be to change the fields from,
e.g., "char" to "long", and change the tests to be N * sizeof(long).

Sorry about that.

Ian

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH, testsuite] Fix usage of sizeof in testsuite/g++.dg/cpp0x/rv[1..8]p.C
  2010-08-13 20:56 ` Ian Lance Taylor
@ 2010-08-14 12:37   ` Uros Bizjak
  0 siblings, 0 replies; 3+ messages in thread
From: Uros Bizjak @ 2010-08-14 12:37 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1390 bytes --]

On Fri, Aug 13, 2010 at 10:43 PM, Ian Lance Taylor <iant@google.com> wrote:

> Hmmm, actually, looking at the patch, I'm not sure this is the best
> approach.  The problem is that your patch means that some of the tests
> no longer actually test anything.  E.g., in rv2p.C, we have this:
>
>    sa<sizeof(sink_2_13(a))           == 1> t1;
>    sa<sizeof(sink_2_13(va))          == 3> t3;
>
> The point of this test is to check function overloading.  Change both
> instances to != 0 means that the test is no longer testing anything.
>
> So a better approach here is going to be to change the fields from,
> e.g., "char" to "long", and change the tests to be N * sizeof(long).

Thanks, attached is fixed patch that implements your suggestion.

2010-08-14  Uros Bizjak  <ubizjak@gmail.com>

	* g++.dg/cast.C: Change fields of structures to "long" to pass
	the test on targets with STRUCTURE_SIZE_BOUNDARY != BITS_PER_UNIT.
	* g++.dg/cpp0x/iop.C: Ditto.
	* g++.dg/cpp0x/named_refs.C: Ditto.
	* g++.dg/cpp0x/rv1p.C: Ditto.
	* g++.dg/cpp0x/rv2p.C: Ditto.
	* g++.dg/cpp0x/rv3p.C: Ditto.
	* g++.dg/cpp0x/rv4p.C: Ditto.
	* g++.dg/cpp0x/rv5p.C: Ditto.
	* g++.dg/cpp0x/rv6p.C: Ditto.
	* g++.dg/cpp0x/rv7p.C: Ditto.
	* g++.dg/cpp0x/rv8p.C: Ditto.
	* g++.dg/cpp0x/unnamed_refs.C: Ditto.

Patch was tested on x86_64-pc-linux-gnu and committed to mainline SVN.

Uros.

[-- Attachment #2: t.diff.txt.bz2 --]
[-- Type: application/x-bzip2, Size: 9331 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-08-14 12:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-13  7:26 [PATCH, testsuite] Fix usage of sizeof in testsuite/g++.dg/cpp0x/rv[1..8]p.C Uros Bizjak
2010-08-13 20:56 ` Ian Lance Taylor
2010-08-14 12:37   ` Uros Bizjak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).