Article View: comp.std.c++
Article #3432Re: Type conflicts
From: Steve Clamage
Date: Fri, 23 Feb 1996 22:38
Date: Fri, 23 Feb 1996 22:38
26 lines
1629 bytes
1629 bytes
In article fsf@pil.idt.unit.no, erikoest@idt.unit.no (Erik Oestlyngen) writes: > >When i define two different structs with the same name in two >different files, my compiler don't complain. I can then use the struct >as input parameter for a function in one file, and from the other send >the different struct into the function. The function will then get >an other input type than it expects. >What does the ansi-C++ standard say about this? The One-Definition Rule says in part that two types with the same name in the same scope must have the same definition. Your code violates the One-Definition Rule, and has undefined behavior. The compiler is not required to diagnose the error. --- Steve Clamage, stephen.clamage@eng.sun.com [ To submit articles: Try just posting with your newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html Comments? mailto:std-c++-request@ncar.ucar.edu ]
Technical Details
Message-ID:
<4gl8f4$aum@engnews1.Eng.Sun.COM>Path:
arc1-ca.pugleaf.net!taumet.Eng.Sun.COM!clamageReferences:
<ye7bumpal7p.fsf@pil.idt.unit.no>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!taumet.Eng.Sun.COM!clamage From: clamage@Eng.sun.com (Steve Clamage) Newsgroups: comp.std.c++ Subject: Re: Type conflicts Date: 23 Feb 1996 22:38:27 GMT Organization: Sun Microsystems Inc. Approved: clamage@eng.sun.com (comp.std.c++) Message-ID: <4gl8f4$aum@engnews1.Eng.Sun.COM> References: <ye7bumpal7p.fsf@pil.idt.unit.no> Reply-To: clamage@Eng.sun.com NNTP-Posting-Host: taumet.eng.sun.com Content-Type: text X-Nntp-Posting-Host: taumet.eng.sun.com Content-Length: 740 X-Lines: 20 Originator: clamage@taumet.Eng.Sun.COM