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++/33902] New: alias warning returning typeid(void)


I distilled the following from boost, in the following discussion:
http://lists.boost.org/boost-users/2007/10/31690.php

namespace std { class type_info { }; }

struct Cow {
  const std::type_info& moo() {
    return typeid(void);
  }
};

gcc4.3 -O2 -Wall -c reduced.cpp

Complains:
reduced.cpp: In member function 'const std::type_info& Cow::moo()':
reduced.cpp:5: warning: dereferencing type-punned pointer will break
strict-aliasing rules

This is gcc version 4.3.0 20071012 (experimental) (GCC).

The test case was reduced from something that #included the appropriate header
files for the type_info / typeid stuff; substitute that if you don't feel
comfortable with defining my own incompatible type_info.


-- 
           Summary: alias warning returning typeid(void)
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: benoit dot hudson at gmail dot com
GCC target triplet: i386-apple-darwin8.10.2


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


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