Issue 97325 - WaE: Warning: Types cannot be declared in anonymous union.
Summary: WaE: Warning: Types cannot be declared in anonymous union.
Status: CONFIRMED
Alias: None
Product: Calc
Classification: Application
Component: code (show other issues)
Version: recent-trunk
Hardware: Unknown All
: P3 Trivial (vote)
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-12-16 19:21 UTC by jens-heiner.rechtien
Modified: 2017-05-20 11:33 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
potential simple fix? (1.15 KB, patch)
2008-12-17 08:57 UTC, Stephan Bergmann
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this issue.
Description jens-heiner.rechtien 2008-12-16 19:21:18 UTC
New compiler warning (SunStudio12) breaks build (because of WaE): 

  "Warning: Types cannot be declared in anonymous union."

Happens in "sc/inc/refdata.hxx", union declared in line 81.

I looked it up, and yes, the compiler is right about the warning as far as the
standard is concerned.

A possible solution would be to give the union a name, but this requires a
number of changes all over the place.

Unfortunately this header is included in a number of source files, so I decided
to disable the warning globally. Please remove the warning tag "anonnotype" from
the -erroff list in solenv/inc/unxsols4.mk when this issue is done.
Comment 1 Stephan Bergmann 2008-12-17 08:57:14 UTC
Created attachment 58877 [details]
potential simple fix?
Comment 2 ooo 2008-12-17 11:26:22 UTC
Might do. However, do I understand this correctly that the problem is BOOL which is
typedef sal_Bool BOOL;
an using directly a POD such as unsigned char instead would not give this warning?
Theoretically, using BOOL is questionable anyway and works only if the type is
capable of holding at least 8 bits.. which also isn't guaranteed for unsigned
char. If the problem is the typedef then also using sal_uInt8 would not do and
we have to use the approach the attached patch takes.
Comment 3 Stephan Bergmann 2008-12-17 11:55:10 UTC
@er: the problem is not some typedef but the struct declaration inside the
anonymous union (IIUC)
Comment 4 ooo 2008-12-17 14:38:27 UTC
Ah, I see, was mislead. I wonder though why that should not be allowed.

@hr: sc/inc/compiler.hxx has similar union{struct{}} in ScDoubleRawToken and
ScRawToken, didn't that break as well?
Comment 5 jens-heiner.rechtien 2008-12-17 16:37:12 UTC
@er: yup, same warning in sc/inc/compiler.hxx line 133 and 158.
Comment 6 jens-heiner.rechtien 2008-12-17 16:50:47 UTC
From the ISO C++ standard (ISO/IEC 14882:1998(E) -- C++ -- Classes):

-- snip --
-2- A union of the form

    union { member-specification } ;

is called an anonymous union; it defines an unnamed object of unnamed type. The
member-specification of an anonymous union shall only define non-static data
members. [Note: nested types and functions cannot be declared within an
anonymous union. ] 
-- snip --

The note in the standard clarifies that an anonymous union can't have nested
types. I guess it has something to do with storage classes ... 
Comment 7 Marcus 2017-05-20 11:33:34 UTC
Reset assigne to the default "issues@openoffice.apache.org".