Closed Bug 839852 Opened 11 years ago Closed 11 years ago

ASan builds fail with "unknown type name 'size_t'" in Asan.h

Categories

(Core :: JavaScript Engine, defect)

x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: smontagu, Unassigned)

References

Details

Attachments

(1 file)

The checkin for bug 723228 broke ASan builds:

In file included from /home/smontagu/mozwork/hgtree/mozilla/js/src/ds/LifoAlloc.cpp:8:
In file included from /home/smontagu/mozwork/hgtree/mozilla/js/src/ds/LifoAlloc.h:11:
./../../dist/include/mozilla/ASan.h:16:63: error: unknown type name 'size_t'
  void __asan_poison_memory_region(void const volatile *addr, size_t size)
                                                              ^
./../../dist/include/mozilla/ASan.h:18:65: error: unknown type name 'size_t'
  void __asan_unpoison_memory_region(void const volatile *addr, size_t size)

The obvious fix is to back out the reordering of the #includes in http://hg.mozilla.org/mozilla-central/diff/d49cff40b5c3/js/src/ds/LifoAlloc.h, but it might be more bullet-proof just to #include stddef.h in ASan.h
> h, but it might be more bullet-proof just to #include stddef.h in ASan.h

Is the <stddef.h>-style #include the preferred way, or should that be #include <cstddef>?
Stddef.h it is.
Attachment #712243 - Flags: review?(smontagu)
Comment on attachment 712243 [details] [diff] [review]
Included stddef.h in ASan.h

Looks good to me, but I'm not a peer for this code.
Attachment #712243 - Flags: review?(smontagu) → review?(jwalden+bmo)
(though I can testify that the patch compiles)
I see, thanks for changing the reviewer!
Comment on attachment 712243 [details] [diff] [review]
Included stddef.h in ASan.h

Review of attachment 712243 [details] [diff] [review]:
-----------------------------------------------------------------

You want <stddef.h> because <cstddef> isn't guaranteed to define ::size_t.  It might provide it, or it might not -- only guarantee is it'd provide std::size_t.
Attachment #712243 - Flags: review?(jwalden+bmo) → review+
...and it looks like someone already got there first:

changeset:   121464:df066a85126f
user:        Christian Holler <choller@mozilla.com>
date:        Sun Feb 10 13:11:04 2013 +0100
summary:     No bug - Include missing header in mfbt/ASan.h. r=me

Bleeding edge can be fun sometimes, eh?
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
> You want <stddef.h> because <cstddef> isn't guaranteed to define ::size_t. 
> It might provide it, or it might not -- only guarantee is it'd provide
> std::size_t.

Quite, however I usually prefer to use the C++ headers and either use std::size_t, or add "using std::size_t;". I don't see having to use std::size_t as a problem.
Perhaps the perfect image of a modern major C++ codebase (sorry, couldn't resist :-) ) would use std::size_t everywhere.  Mozilla, however, is a C++ codebase with strong C influences from having grown up in a time when C++ compiler support was (and to some extent remains) distinctly uneven, so we're more likely to use C headers than the corresponding C++ headers, if we're not using functionality only in the C++ headers.

There are also times where we actively care about our code being the C subset of C++.  This header isn't such a time yet, but I could see it becoming one at some point.  (Tho I'd rather we stopped using C and just used C++ exclusively [even if it's only the C subset of C++], but that's a harder battle to fight.)
No problem. Thank you for explaining.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: