compiling some template classes and got error re anonymous struct not in named type

Bug #544783 reported by Dean Z. Douthat
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
gcc
Fix Released
Medium
gcc-4.4 (Ubuntu)
Triaged
Low
Unassigned

Bug Description

Binary package hint: gcc-4.4

Ubuntu 9.10, gcc 4.4.1

Got error report about anonymous struct not inside of named type. This code compiled OK under Microsoft Visual Studio 2007. After error report, "confused by earlier errors, bailing out"

ProblemType: Crash
Architecture: amd64
Date: Tue Mar 23 00:05:01 2010
DistroRelease: Ubuntu 9.10
ExecutablePath: /usr/lib/gcc/x86_64-linux-gnu/4.4.1/cc1plus
InstallationMedia: Ubuntu 9.10 "Karmic Koala" - Release amd64 (20091027)
NonfreeKernelModules: nvidia
Package: g++-4.4 4.4.1-4ubuntu9
ProcVersionSignature: Ubuntu 2.6.31-20.58-generic
SourcePackage: gcc-4.4
Uname: Linux 2.6.31-20-generic x86_64

Revision history for this message
Dean Z. Douthat (deanz1) wrote :
Revision history for this message
In , Matthias Klose (doko) wrote :

seen with 4.3, 4.4, 4.5 and trunk:

Starting program: /scratch/packages/gcc/4.4/gcc-4.4-4.4.4/build/gcc/cc1plus -fpreprocessed ../../Vector3D.ii -quiet -dumpbase Vector3D.ii -mtune=generic -auxbase Vector3D -version -fpermissive -o /tmp/ccG8KwAM.s
GNU C++ (Debian 4.4.4-6) version 4.4.4 (x86_64-linux-gnu)
        compiled by GNU C version 4.4.4, GMP version 4.3.2, MPFR version 2.4.2-p1.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 98feda5ccf2f6c27a26b5ced57e2b3dd
In file included from Vector3D.cpp:4:
Vector3D.h: In member function 'Vec<FP_>& Vec<FP_>::operator^=(Vec<FP_>&)':
Vector3D.h:112: error: anonymous struct not inside named type
Vector3D.h: In member function 'Vec<FP_>& Vec<FP_>::operator^=(Vec<FP_>&) [with FP_ = double]':
Vector3D.cpp:19: instantiated from here
Vector3D.h:112: error: anonymous struct not inside named type

Program received signal SIGSEGV, Segmentation fault.
tsubst_copy_and_build (t=0x0, args=0x7ffff6112fc0, complain=tf_warning_or_error,
    in_decl=0x7ffff62b2c80, function_p=<value optimized out>,
    integral_constant_expression_p=<value optimized out>) at ../../src/gcc/cp/pt.c:11716
11716 if (BASELINK_P (member))
(gdb) p member
$1 = (tree) 0x0

Revision history for this message
In , Matthias Klose (doko) wrote :

Created attachment 20974
preprocessed source

Revision history for this message
Matthias Klose (doko) wrote :

ICE on error recovery, seen with 4.3, 4.4, 4.5, trunk

Changed in gcc-4.4 (Ubuntu):
importance: Undecided → Low
status: New → Triaged
Revision history for this message
In , Manu-gcc (manu-gcc) wrote :

Confirmed in trunk. A reduce testcase would be helpful:

http://gcc.gnu.org/bugs/minimize.html

Changed in gcc:
status: Unknown → Confirmed
Revision history for this message
In , Rguenth (rguenth) wrote :

Reduced testcase (but with more and slightly different errors)

template<typename FP_> class Vec {
    Vec& operator^=(Vec& rhs) {
        union {
            struct {FP_ x,y,z;};
        };
        X = y*rhs.z() - z*rhs.y();
    }
    Vec& operator^(Vec& rhs) {
        return Vec(*this)^=rhs;
    }
};
Vec<double> v(3,4,12);
Vec<double>V(12,4,3);
Vec<double> c = v^V;

Revision history for this message
In , Paolo-carlini (paolo-carlini) wrote :

On it.

Changed in gcc:
status: Confirmed → In Progress
Revision history for this message
In , stevenb (steven-gcc) wrote :

Paolo, still on it?

Changed in gcc:
importance: Unknown → Medium
status: In Progress → Confirmed
Revision history for this message
In , Paolo-carlini (paolo-carlini) wrote :

On it (again ;)

Revision history for this message
In , Paolo-k (paolo-k) wrote :

Author: paolo
Date: Thu Jun 23 16:58:28 2011
New Revision: 175344

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=175344
Log:
/cp
2011-06-23 Paolo Carlini <email address hidden>

 PR c++/44625
 * decl2.c (build_anon_union_vars): Early return error_mark_node
 for a nested anonymous struct.

/testsuite
2011-06-23 Paolo Carlini <email address hidden>

 PR c++/44625
 * g++.dg/template/crash107.C: New.
 * g++.dg/template/error17.C: Adjust.

Added:
    trunk/gcc/testsuite/g++.dg/template/crash107.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/decl2.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/template/error17.C

Revision history for this message
In , Paolo-carlini (paolo-carlini) wrote :

Fixed for 4.7.0.

Changed in gcc:
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.