473,563 Members | 2,831 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

help?: incomplete definition with complete definition in scope

Ark
Hello NG,
Consider the following snippet:
struct x_t x;
struct x_t {
int y;
};
Different compilers disagree (in "strict ANSI" mode) whether it is
legal. What is the truth (in C90 and C99 and anywhere in between)?
C99 seems to list UB case when the complete definition is not in the
same scope as declaration, but in this case it is...
Thank you,
Ark
Nov 14 '05 #1
1 1267
In article <i_************ ********@comcas t.com>
Ark <ak*****@macroe xpressions.com> writes:
Consider the following snippet:
struct x_t x;
struct x_t {
int y;
};
Different compilers disagree (in "strict ANSI" mode) whether it is
legal. What is the truth (in C90 and C99 and anywhere in between)?
The actual text of the wording in the Standards suggests that it
is OK, but the "design" of C -- which aims for all the necessary
information to be available in a one-pass compiler, and it would
not be at that point -- suggests that it is not OK. (Hence it is
not surprising that different C compilers disagree as to whether
this code is strictly conforming.)
C99 seems to list UB case when the complete definition is not in the
same scope as declaration, but in this case it is...


This kind of question really belongs in comp.std.c, since it amounts
to argument over whether a "shall" on page 123 is more important
than some other words on page 97, etc. Here in comp.lang.c the
answer boils down to "don't do that" (because people, and compilers,
cannot agree as to whether it is OK :-) ).
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: forget about it http://web.torek.net/torek/index.html
Reading email is like searching for food in the garbage, thanks to spammers.
Nov 14 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
4940
by: Andrew Ward | last post by:
Hi All, Considering the following code: struct A; struct B { std::list<A> l; };
3
2194
by: JackC | last post by:
Hi Problem: I wish to use a pimpl to hide implementation/storage of a class (T), but I also want to hold objects of that class (T) in an std::vector<T> (or similar). T is non trivial (i.e. not POD, because it has std::string and other classes requiring proper destruction, although all drill down to POD and strings eventually). Classic...
24
2081
by: ark | last post by:
Hello group, Could you help me with this: static const int x; ............ something ............. static const int x = 17; It looks perfectly legal to me but MSVC/C++ 6.0 gives, on the first line, "warning C4132: 'x' : const object should be initialized" yet generates correct code.
2
40832
by: Halid Umar A M | last post by:
Dear All, Please tell me why this error is occuring. The following is the code snippets which i have typed. struct mystructure{ struct list_head m; //error: field m has incomplete type uint32_t ip; time_t time; };
2
15108
by: gk245 | last post by:
I have something like this: #include <stdio.h> #include <ctype.h> #include <strings.h> struct sentence get_sentence (char string) { struct sentence my_sentence {
1
3833
by: Alan Johnson | last post by:
From the standard 5.3.5/5: "If the object being deleted has incomplete class type at the point of deletion and the complete class has a non-trivial destructor or a deallocation function, the behavior is undefined." In the program below, what constitutes "point of deletion"? Presumably, since delete is called somewhere within shared_ptr's...
7
4700
by: for.fun | last post by:
Hi everybody, I have the following problem : B class need A::MyEnum type and A class need B::MyEnum type. In both case, the class type is incomplete so it is obvious that the ::MyEnum can not be found in the class definition (the compiler complains) My problem is the MyEnum types have to be defined inside the class
9
1624
by: rammel | last post by:
class1.h ----------- #ifndef CLASS1_H_ #define CLASS1_H_ #include "class2.h" // inclusion class class2; // and forward class class1 { private:
50
4436
by: Juha Nieminen | last post by:
I asked a long time ago in this group how to make a smart pointer which works with incomplete types. I got this answer (only relevant parts included): //------------------------------------------------------------------ template<typename Data_t> class SmartPointer { Data_t* data; void(*deleterFunc)(Data_t*);
0
7583
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7885
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7948
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6250
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5484
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3642
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2082
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.