Topic: int 3; compiles
Author: bradds@concentric.net (Bradd W. Szonye)
Date: 1996/10/08 Raw View
Michael Taylor <michaelt@asymetrix.com> wrote in article
<53c24d$8uu@loki.asymetrix.com>...
> "Pete Rowley" <pete.rowley@octel.com> wrote:
> >Quite by accident, I typed
>
> >int 3;
>
> >in Micrsoft Visual C++ v. 4.1 and it compiled without error - is this
> >legal?
>
> I think you added an inline assembly statement. int 3 is the debug
> breakpoint instruction.
>
> [ mod note: Let's try to keep the discussion focussed on the language
> definition, although it is all right to mention special properties
> of the compiler in question. -sdc ]
[Bradd note: I'll try to keep it focused...]
Actually, I suspect it's more like a subtle interaction between the C++
grammar (ick) and the Microsoft inline assembly grammar (double ick).
C++ defines an asm-directive as
asm ( "assembly-directive string literal" );
Microsoft, however, traditionally has an extension
asm intel_assembly_opcode operand1, operand2
Given the nasty, ambiguous, context-sensitive C++ grammar combined with
years of maintenance upgrades dating back (possibly) to the original C
compiler, it's not inconceivable that the C++ syntax
int declarator = expression; // C++ variable
got mixed up with
int 3; // Intel breakpoint interrupt
This makes even more sense given that there's some sort of bug in that
version of the compiler that garbles enum values when put into inline
assembly directives. Other possible culprits include bugs in the declarator
syntax or in the cast-expression syntax, although I suspect that bugs there
would show up in other places too. I should also note that the bug is "not
reproducible" here in VC++ 4.2; either the bug is yours or it was theirs
and they fixed it.
Speaking of asm-directives, is there a reason why it's not defined as
asm { pp-token-seq }
instead? I saw an argument against such a construction in a C9x proposal
for "inline" pragmas, comparing the pragma-token sequence "pragma(
"pragma-string-literal" )" to "pragma( pp-token-seq )". I didn't completely
understand why string-literals are preferable to preprocessor tokens. I
suppose the same question goes for extern linkage-specifiers. It's a nit,
as a compiler could (?) allow
extern (Pascal) { /* ... */ }
or
asm { int 3 }
without breaking strictly-conforming programs--I think. The main
disadvantage is that such extensions are exceedingly non-portable, but
then, asm-directives are non-portable anyway.
--
Bradd W. Szonye
bradds@concentric.net
http://www.concentric.net/~bradds
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. 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 ]
Author: "Pete Rowley" <pete.rowley@octel.com>
Date: 1996/10/07 Raw View
Quite by accident, I typed
int 3;
in Micrsoft Visual C++ v. 4.1 and it compiled without error - is this
legal?
--
Pete Rowley
Software Engineer, Octel Communications, Client/Server Software Division
Current Technical Interests: OOD, C++, Exchange, MAPI, Quake Soak Testing
---
[ comp.std.c++ is moderated. To submit articles: Try just posting with your
newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
Comments? mailto:std-c++-request@ncar.ucar.edu
]
Author: michaelt@asymetrix.com (Michael Taylor)
Date: 1996/10/08 Raw View
"Pete Rowley" <pete.rowley@octel.com> wrote:
>Quite by accident, I typed
>int 3;
>in Micrsoft Visual C++ v. 4.1 and it compiled without error - is this
>legal?
I think you added an inline assembly statement. int 3 is the debug
breakpoint instruction.
[ mod note: Let's try to keep the discussion focussed on the language
definition, although it is all right to mention special properties
of the compiler in question. -sdc ]
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. 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 ]
Author: "Donley R. P'Simer" <donley@mindspring.com>
Date: 1996/10/08 Raw View
int main()
{
int 3;
return 0;
}
produces the following error in MSVC++ v4.1:
Compiling...
test.cpp
C:\users\donleyp\test\test.cpp(3) : error C2143: syntax error : missing
';' before 'int constant'
Error executing cl.exe.
test.exe - 1 error(s), 0 warning(s)
Maybe there's more to it than what I put up there. Could you post the
origional code?
Donley
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. 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 ]