Skip to content

Commit

Permalink
change jl_get_field_offset to test validity of and return the specifi…
Browse files Browse the repository at this point in the history
…ed field offset
  • Loading branch information
vtjnash committed Jan 21, 2016
1 parent 47c26dc commit 30a44c9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -631,9 +631,9 @@ JL_DLLEXPORT long jl_SC_CLK_TCK(void)

JL_DLLEXPORT size_t jl_get_field_offset(jl_datatype_t *ty, int field)
{
if (field > jl_datatype_nfields(ty))
if (field > jl_datatype_nfields(ty) || field < 1)
jl_error("This type does not have that many fields");
return jl_field_offset(ty, field);
return jl_field_offset(ty, field-1);

This comment has been minimized.

Copy link
@yuyichao

yuyichao Jan 22, 2016

Contributor

Is this (and Base.field_offset) used anywhere?

This comment has been minimized.

Copy link
@vtjnash

vtjnash Jan 22, 2016

Author Member

only https://github.com/Keno/Cxx.jl/blob/e9168edc0316a87e24398a53700c961f431c64ad/src/exceptions.jl#L80, according to github search

it's not exported or tested. it looks like it snuck in when I squashed commits to create 9053bff

}

JL_DLLEXPORT size_t jl_get_alignment(jl_datatype_t *ty)
Expand Down

0 comments on commit 30a44c9

Please sign in to comment.