Comment 1 for bug 770836

Revision history for this message
Kevin M. Buckley (kevin-m-buckley) wrote :

I don't pretend to understand the actual C++ issue here but the build log snippet
that was posted misses something that might help solve the problem, vis, the two
lines above the snippet which detail the actual error and where the compiler suggests
how to avoid it

/build/buildd/kompozer-0.8~b3.dfsg.1/mozilla/layout/style/nsCSSStyleSheet.cpp: In function 'PRBool AttrMatchesValue(const nsAttrSelector*, const nsString&)':
/build/buildd/kompozer-0.8~b3.dfsg.1/mozilla/layout/style/nsCSSStyleSheet.cpp:2897:43: error: uninitialized const 'ciComparator' [-fpermissive]
../../dist/include/unicharutil/nsUnicharUtils.h:63:7: note: 'const class nsCaseInsensitiveStringComparator' has no user-provided default constructor

For reasons I won't go into here I came to build FireFox2 (yes, 2!) and have seen the same error and
then found this thread whilst looking for an answer.

The lines of relevant code in nsCSSStyleSheet.cpp are these

...
  const nsDefaultStringComparator defaultComparator;
  const nsCaseInsensitiveStringComparator ciComparator;
  const nsStringComparator& comparator = aAttrSelector->mCaseSensitive
                ? NS_STATIC_CAST(const nsStringComparator&, defaultComparator)
                : NS_STATIC_CAST(const nsStringComparator&, ciComparator);
...

but note that there's only one place where the variable for which the declaration
is causing the error, ciComparator, is used.

Elsewhere in the firefox codebase, you don't see declarations such as the above
but you do see a "default constructor" referred to, vis:

nsCaseInsensitiveStringComparator()

I therefore modified nsCSSStyleSheet.cpp to just use the default constructor in place
and not declare the "intermediate" variable.

  const nsDefaultStringComparator defaultComparator;
  const nsStringComparator& comparator = aAttrSelector->mCaseSensitive
                ? NS_STATIC_CAST(const nsStringComparator&, defaultComparator)
                : NS_STATIC_CAST(const nsStringComparator&, nsCaseInsensitiveStringComparator() );

This at least allows nsCSSStyleSheet.cpp to compile.

I also ran the compile of that individual source file using -fpermissive and that "defeats"
the error too.

As I say, it may not be the correct/complete solution, but maybe the info will help point
someone else to it.