[Bug c++/13051] New: problem with static member and ?: operator

mihai_preda at yahoo dot com gcc-bugzilla@gcc.gnu.org
Fri Nov 14 14:46:00 GMT 2003


class A {
public:
    static const int a = 1;
    static const int b = 2;
};

int main(int argc) {
    return (argc == 0) ? A::a : A::b;

    /*                                                                         
                                                      
    if (argc == 0) {                                                           
                                                      
        return A::a;                                                           
                                                      
    } else {                                                                   
                                                      
        return A::b;                                                           
                                                      
    }                                                                          
                                                      
    */
}

when linking, I get
/tmp/ccEecr0u.o: In function `main':
/tmp/ccEecr0u.o(.text+0x17): undefined reference to `A::b'
/tmp/ccEecr0u.o(.text+0x21): undefined reference to `A::a'

But when I use the commented-out 'if' instead of '?:', it compiles&links OK.

$g++ -v
Lecture des spécification à partir de
/xyleme/Linux/gcc3/usr/gcc/lib/gcc-lib/i686-pc-linux-gnu/3.2.3/specs
Configuré avec: ./configure --prefix=/xyleme/Linux/gcc3/usr/gcc --enable-threads
Modèle de thread: posix
version gcc 3.2.3

$uname -a
Linux xxx 2.4.18-64GB-SMP #1 SMP Wed Mar 27 13:58:12 UTC 2002 i686 unknown

-- 
           Summary: problem with static member and ?: operator
           Product: gcc
           Version: 3.2.3
            Status: UNCONFIRMED
          Severity: minor
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: mihai_preda at yahoo dot com
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13051



More information about the Gcc-bugs mailing list