Closed Bug 1285640 Opened 6 years ago Closed 6 years ago

CountingAllocatorBase.h:56:12: error: instantiation of variable 'mozilla::CountingAllocatorBase<HunspellAllocator>::sAmount' required here, but no definition is available [-Werror,-Wundefined-var-template]

Categories

(Core :: Spelling checker, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla50
Tracking Status
firefox50 --- fixed

People

(Reporter: dholbert, Assigned: dholbert)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

I tried building with clang 3.9 today, and I got this build warning (treated as an error due to --enable-warnings-as-errors in my mozconfig):
{
$OBJ/dist/include/mozilla/CountingAllocatorBase.h:56:12: error: instantiation of variable 'mozilla::CountingAllocatorBase<HunspellAllocator>::sAmount' required here, but no definition is available [-Werror,-Wundefined-var-template]
    return sAmount;
           ^
$SRC/extensions/spellcheck/hunspell/glue/mozHunspell.h:108:74: note: in instantiation of member function 'mozilla::CountingAllocatorBase<HunspellAllocator>::MemoryAllocated' requested here
      "explicit/spell-check", KIND_HEAP, UNITS_BYTES, HunspellAllocator::MemoryAllocated(),
                                                                         ^
$OBJ/dist/include/mozilla/CountingAllocatorBase.h:130:25: note: forward declaration of template entity is here
  static Atomic<size_t> sAmount;
                        ^
$OBJ/dist/include/mozilla/CountingAllocatorBase.h:56:12: note: add an explicit instantiation declaration to suppress this warning if 'mozilla::CountingAllocatorBase<HunspellAllocator>::sAmount' is explicitly instantiated in another translation unit
    return sAmount;
           ^
1 error generated.
}
The error happens while compiling mozilla/extensions/spellcheck/src/mozSpellCheckerFactory.cpp, btw -- I was missing this bit of the build error output in my comment 0 quote:
> In the directory $OBJ/extensions/spellcheck/src
> The following command failed to execute properly:
> clang++ -m64 -std=gnu++11 -o mozSpellCheckerFactory.o -c [...]
> [...]
> make[5]: *** [mozSpellCheckerFactory.o] Error 1
(The patch just cuts and pastes the function definition, plus some reindentation/rewrapping for readability/coding-style-adherence.)
I've verified locally that this patch gets me past this build warning/error, BTW.
Assignee: nobody → dholbert
Blocks: 1285668
Comment on attachment 8769331 [details]
Bug 1285640: Move mozHunspell::CollectReports definition from .h file to .cpp file, to avoid clang 3.9 warning about static variable declared in header.

https://reviewboard.mozilla.org/r/63284/#review60220
Attachment #8769331 - Flags: review?(n.nethercote) → review+
Pushed by dholbert@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/ec17a17df4b7
Move mozHunspell::CollectReports definition from .h file to .cpp file, to avoid clang 3.9 warning about static variable declared in header. r=njn
https://hg.mozilla.org/mozilla-central/rev/ec17a17df4b7
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla50
You need to log in before you can comment on or make changes to this bug.