Test your C/C++ Skills [Free Online Test]

K

Keith Thompson

Kenneth Brody said:
It depends on the definition of "c".

For example, given the definition "const int c;", the expression
"c/c++" is well defined. (FSVO "defined".)

:)

It's a constraint violation. The only requirement on the
implementation is that it must produce a diagnostic. Once it's
produced that diagnostic, it's free to continue to translate the
program, which may then execute but whose behavior is not defined
by the standard.
 
F

Flash Gordon

Keith said:
It's a constraint violation. The only requirement on the
implementation is that it must produce a diagnostic.

Which, of course, is the 'VI "defined"' to hich Kenneth was referring.
Once it's
produced that diagnostic, it's free to continue to translate the
program, which may then execute but whose behavior is not defined
by the standard.

True, but it's defined as producing a diagnostic during translation.
 
K

Keith Thompson

Flash Gordon said:
Which, of course, is the 'VI "defined"' to hich Kenneth was referring.


True, but it's defined as producing a diagnostic during translation.

Pedant!
 
K

Keith Thompson

Kenneth Brody said:
Thanks. :)


This group thrives on pedantry.

Okay, what about:

extern void c(void);

Are we in the realm of "must fail to compile" yet?

Nope. The only case where something "must fail to compile" is
when a #error directive survives any #if and #ifdef directives.
In all other cases (constraint violations, syntax rule violations,
undefined behavior, hard drive containing source has lost power), the
compiler is free to proceed after issuing any required diagnostics.
 
K

Keith Thompson

Kenneth Brody said:
That's what I remembered after clicking "send". :-|

(And, of course, macros can't expand to preprocessor directives.)

So, technically, syntax rule violations are also UB? (Can a compiler
print a diagnostic and then reformat the hard drive, and still be
"conforming"?)

Yes. When you sue the vendor for reformatting your hard drive, you
won't be able to claim that the compiler is non-conforming.
 
P

Phil Carmody

Kenneth Brody said:
That's what I remembered after clicking "send". :-|

(And, of course, macros can't expand to preprocessor directives.)

So, technically, syntax rule violations are also UB? (Can a compiler
print a diagnostic and then reformat the hard drive, and still be
"conforming"?)

We prefer to call that model the 'conformatting' version.

Phil
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top