* Why is ptrdiff_t a volatile?
@ 2018-10-01 7:24 Toby Douglass
2018-10-01 9:10 ` Marc Glisse
0 siblings, 1 reply; 4+ messages in thread
From: Toby Douglass @ 2018-10-01 7:24 UTC (permalink / raw)
To: gcc-help
Good morning/afternoon/evening, all.
I've been writing some position independent data structure code.
As such, I've been using ptrdiff_t.
I've just noticed, while compiling, that my GCC (6.3.0) has ptrdiff_t as
a volatile long int.
It is not clear to me why this type would be volatile.
I've googled, no luck.
So, why volatile?
Anyone know the rationale?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Why is ptrdiff_t a volatile?
2018-10-01 7:24 Why is ptrdiff_t a volatile? Toby Douglass
@ 2018-10-01 9:10 ` Marc Glisse
2018-10-01 9:31 ` Toby Douglass
0 siblings, 1 reply; 4+ messages in thread
From: Marc Glisse @ 2018-10-01 9:10 UTC (permalink / raw)
To: Toby Douglass; +Cc: gcc-help
On Mon, 1 Oct 2018, Toby Douglass wrote:
> Good morning/afternoon/evening, all.
>
> I've been writing some position independent data structure code.
>
> As such, I've been using ptrdiff_t.
>
> I've just noticed, while compiling, that my GCC (6.3.0) has ptrdiff_t as a
> volatile long int.
I doubt gcc does that. More likely your code has a broken macro somewhere.
You don't provide enough information for us to help more...
--
Marc Glisse
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Why is ptrdiff_t a volatile?
2018-10-01 9:10 ` Marc Glisse
@ 2018-10-01 9:31 ` Toby Douglass
2018-10-01 12:10 ` Jonathan Wakely
0 siblings, 1 reply; 4+ messages in thread
From: Toby Douglass @ 2018-10-01 9:31 UTC (permalink / raw)
To: gcc-help
On 01/10/2018 11:10, Marc Glisse wrote:
> On Mon, 1 Oct 2018, Toby Douglass wrote:
>
>> Good morning/afternoon/evening, all.
>>
>> I've been writing some position independent data structure code.
>>
>> As such, I've been using ptrdiff_t.
>>
>> I've just noticed, while compiling, that my GCC (6.3.0) has ptrdiff_t
>> as a volatile long int.
>
> I doubt gcc does that. More likely your code has a broken macro
> somewhere. You don't provide enough information for us to help more...
I thought I'd given enough for the question :-)
But I think you might be right indeed.
I've just had another line of output from GCC when it's unhappy with my
code, which is this;
"note: expected âlfds720_pal_uint_t * {aka long long unsigned int *}â
but argument is of type âptrdiff_t * {aka long int *}â"
Now before I was being told a ptrdiff_t was a volatile long int.
It looks like if I add volatile to a type, it turns up in the "aka".
I was not expecting this - I thought the aka would be the underlying
type, sans qualifiers.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Why is ptrdiff_t a volatile?
2018-10-01 9:31 ` Toby Douglass
@ 2018-10-01 12:10 ` Jonathan Wakely
0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Wakely @ 2018-10-01 12:10 UTC (permalink / raw)
To: Toebs Douglass; +Cc: gcc-help
On Mon, 1 Oct 2018 at 10:31, Toby Douglass <toby@winterflaw.net> wrote:
>
> On 01/10/2018 11:10, Marc Glisse wrote:
> > On Mon, 1 Oct 2018, Toby Douglass wrote:
> >
> >> Good morning/afternoon/evening, all.
> >>
> >> I've been writing some position independent data structure code.
> >>
> >> As such, I've been using ptrdiff_t.
> >>
> >> I've just noticed, while compiling, that my GCC (6.3.0) has ptrdiff_t
> >> as a volatile long int.
> >
> > I doubt gcc does that. More likely your code has a broken macro
> > somewhere. You don't provide enough information for us to help more...
>
> I thought I'd given enough for the question :-)
No, because you're just making a claim about GCC's behaviour based on
code we can't see. It t urns out you weren't even basing it on the
code, but on the content of a diagnostic message.
> But I think you might be right indeed.
>
> I've just had another line of output from GCC when it's unhappy with my
> code, which is this;
>
> "note: expected ‘lfds720_pal_uint_t * {aka long long unsigned int *}’
> but argument is of type ‘ptrdiff_t * {aka long int *}’"
>
> Now before I was being told a ptrdiff_t was a volatile long int.
No you weren't.
> It looks like if I add volatile to a type, it turns up in the "aka".
Of course. If ptrdiff_t is a typedef for long int, then ptrdiff_t* is
long int*, and volatile ptrdiff_t* is volatile long int*.
The aka "unwraps" typedefs to show you the actual type, but it doesn't
strip qualifiers, because that would give a different type.
> I was not expecting this - I thought the aka would be the underlying
> type, sans qualifiers.
No, it's the actual type. Otherwise the message would not be very
helpful when it tells you that you can't convert const int* to int*,
because it would just show int* twice.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-10-01 12:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-01 7:24 Why is ptrdiff_t a volatile? Toby Douglass
2018-10-01 9:10 ` Marc Glisse
2018-10-01 9:31 ` Toby Douglass
2018-10-01 12:10 ` Jonathan Wakely
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).