This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/21487] New: new object affectation in a switch


what follows (version, command line, source and .ii) seems to be a bug.

if you need something else -> sebmaestro@hotmail.com.

"bravo et merci quand même pour votre bon boulot !"

seb.

------    Command lines :   ---------

seb$ g++ --version
g++ (GCC) 3.3.6 (Debian 1:3.3.6-4)
Copyright (C) 2003 Free Software Foundation, Inc.
Ce logiciel est libre; voir les sources pour les conditions de copie.  Il n'y a PAS
GARANTIE; ni implicite pour le MARCHANDAGE ou pour un BUT PARTICULIER.

seb$ g++ -Wall -save-temps -o test makebug.cpp 
makebug.cpp: Dans function « int main(int, char**) »:
makebug.cpp:42: error: saut à l'étiquette du « case »
makebug.cpp:40: error:   crosses initialization of `Thing*str'
makebug.cpp:44: error: saut à l'étiquette du « case »
makebug.cpp:40: error:   crosses initialization of `Thing*str'
makebug.cpp:40: attention : unused variable `Thing*str'

----------  source code: (makebug.cpp) -----------  

class Thing {
public:
  Thing() {
  }
};

int main (int argc, char ** argv){

  if (argc == 1) {
    return 0;
  }

  int truc = 0;

  
  switch (truc) {
    
  case 0:
    break;
  case 1:
    Thing *th;
    th = new Thing();
    break;
  case 2:
    break;
  case 3:
    break;


  }




  switch (truc) {
   
  case 0:
    break;
  case 1:
    Thing *str = new Thing;   
    break;
  case 2:                     
    break;
  case 3:
    break;
  }
  return 0;
}


------------   preprocessed file: (makebug.ii) -----------

# 1 "makebug.cpp"
# 1 "<interne>"
# 1 "<ligne de commande>"
# 1 "makebug.cpp"
class Thing {
public:
  Thing() {
  }
};

int main (int argc, char ** argv){

  if (argc == 1) {
    return 0;
  }

  int truc = 0;


  switch (truc) {

  case 0:
    break;
  case 1:
    Thing *th;
    th = new Thing();
    break;
  case 2:
    break;
  case 3:
    break;


  }




  switch (truc) {

  case 0:
    break;
  case 1:
    Thing *str = new Thing;
    break;
  case 2:
    break;
  case 3:
    break;
  }
  return 0;
}

-- 
           Summary: new object affectation in a switch
           Product: gcc
           Version: 3.3.6
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: sebmaestro at hotmail dot com
                CC: gcc-bugs at gcc dot gnu dot org,sebmaestro at hotmail
                    dot com


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]