Re: Question about sizeof after struct change

2020-01-07 Thread Richard Biener
On Mon, Jan 6, 2020 at 12:03 PM Jonathan Wakely wrote: > > On Fri, 3 Jan 2020 at 16:09, Erick Ochoa wrote: > > Do you mean something like taking the address of a struct and adding an > > offset > > to access a field? > > Yes, the following code is valid: > > struct S { int unused; int used; }; >

Re: Question about sizeof after struct change

2020-01-06 Thread Jonathan Wakely
On Fri, 3 Jan 2020 at 16:09, Erick Ochoa wrote: > Do you mean something like taking the address of a struct and adding an offset > to access a field? Yes, the following code is valid: struct S { int unused; int used; }; static_assert( sizeof(S) == 8 ); S s[4]; int* s2_used = (int*)((char*)s + 20)

Re: Question about sizeof after struct change

2020-01-03 Thread Erick Ochoa
On 2019-12-24 2:37 a.m., Richard Biener wrote: > On December 23, 2019 6:30:31 PM GMT+01:00, Erick Ochoa > wrote: >> Hi, >> >> I am working on an LTO pass which drops unused fields on structs. On my >> tests, I found that the gimple generated for `sizeof` is a constant. >> For >> example, for t

Re: Question about sizeof after struct change

2019-12-28 Thread Nathan Sidwell
On 12/23/19 12:30 PM, Erick Ochoa wrote: Hi, I am working on an LTO pass which drops unused fields on structs. On my tests, I found that the gimple generated for `sizeof` is a constant. For example, for the following C code: ``` you also need to pay attention to offsetof. nathan -- Nathan Si

Re: Question about sizeof after struct change

2019-12-23 Thread Richard Biener
On December 23, 2019 6:30:31 PM GMT+01:00, Erick Ochoa wrote: >Hi, > >I am working on an LTO pass which drops unused fields on structs. On my >tests, I found that the gimple generated for `sizeof` is a constant. >For >example, for the following C code: > >``` >struct astruct_s { _Bool c; _Bool a;