Questions tagged [standards-compliance]
355 questions
9401
votes
26 answers
What is the "-->" operator in C/C++?
After reading Hidden Features and Dark Corners of C++/STL on comp.lang.c++.moderated, I was completely surprised that the following snippet compiled and worked in both Visual Studio 2008 and G++ 4.4.
Here's the code:
#include
int main()
{
…
GManNickG
- 459,504
- 50
- 465
- 534
351
votes
13 answers
Is it valid to have a html form inside another html form?
Is it valid html to have the following:
So when you submit "b" you only get the fields within…
FlyByQuestionGuy
323
votes
18 answers
Can an html element have multiple ids?
I understand that an id must be unique within an HTML/XHTML page.
My question is, for a given element, can I assign multiple ids to it?
I realize I have an easy solution with simply using a class. I'm…
webmat
- 50,648
- 12
- 52
- 59
260
votes
6 answers
C++ new int[0] -- will it allocate memory?
A simple test app:
cout << new int[0] << endl;
outputs:
0x876c0b8
So it looks like it works. What does the standard say about this? Is it always legal to "allocate" empty block of memory?
anon
254
votes
6 answers
Do the JSON keys have to be surrounded by quotes?
Example:
Is the following code valid against the JSON Spec?
{
precision: "zip"
}
Or should I always use the following syntax? (And if so, why?)
{
"precision": "zip"
}
I haven't really found something about this in the JSON specifications.…
christianvuerings
- 19,722
- 4
- 20
- 19
144
votes
3 answers
What is going on with 'gets(stdin)' on the site coderbyte?
Coderbyte is an online coding challenge site (I found it just 2 minutes ago).
The first C++ challenge you are greeted with has a C++ skeleton you need to modify:
#include
#include
using namespace std;
int FirstFactorial(int…
bolov
- 58,757
- 13
- 108
- 182
132
votes
12 answers
Is main() really start of a C++ program?
The section $3.6.1/1 from the C++ Standard reads,
A program shall contain a global
function called main, which is the
designated start of the program.
Now consider this code,
int square(int i) { return i*i; }
int user_main()
{
for ( int i = 0…
Nawaz
- 327,095
- 105
- 629
- 812
126
votes
2 answers
When does invoking a member function on a null instance result in undefined behavior?
Consider the following code:
#include
struct foo
{
// (a):
void bar() { std::cout << "gman was here" << std::endl; }
// (b):
void baz() { x = 5; }
int x;
};
int main()
{
foo* f = 0;
f->bar(); // (a)
…
GManNickG
- 459,504
- 50
- 465
- 534
122
votes
2 answers
Does constexpr imply inline?
Consider the following inlined function :
// Inline specifier version
#include
#include
inline int f(const int x);
inline int f(const int x)
{
return 2*x;
}
int main(int argc, char* argv[])
{
return…
Vincent
- 50,257
- 51
- 171
- 339
112
votes
6 answers
Clean way to launch the web browser from shell script?
In a bash script, I need to launch the user web browser. There seems to be many ways of doing this:
$BROWSER
xdg-open
gnome-open on GNOME
www-browser
x-www-browser
...
Is there a more-standard-than-the-others way to do this that would work on most…
nicoulaj
- 3,061
- 4
- 23
- 31
112
votes
5 answers
Declaration of Methods should be Compatible with Parent Methods in PHP
Strict Standards: Declaration of childClass::customMethod() should be compatible with that of parentClass::customMethod()
What are possible causes of this error in PHP? Where can I find information about what it means to be compatible?
waiwai933
- 12,962
- 20
- 61
- 82
109
votes
7 answers
RegEx to parse or validate Base64 data
Is it possible to use a RegEx to validate, or sanitize Base64 data? That's the simple question, but the factors that drive this question are what make it difficult.
I have a Base64 decoder that can not fully rely on the input data to follow the RFC…
LarryF
- 4,617
- 4
- 27
- 40
104
votes
1 answer
Does a dot have to be escaped in a character class (square brackets) of a regular expression?
A dot . in a regular expression matches any single character. In order for regex to match a dot, the dot has to be escaped: \.
It has been pointed out to me that inside square brackets [] a dot does not have to be escaped. For example, the…
Dariusz
- 19,750
- 7
- 65
- 104
69
votes
6 answers
Why does MySQL allow "group by" queries WITHOUT aggregate functions?
Surprise -- this is a perfectly valid query in MySQL:
select X, Y from someTable group by X
If you tried this query in Oracle or SQL Server, you’d get the natural error message:
Column 'Y' is invalid in the select list because it is not contained…
Aaron Fi
- 9,410
- 13
- 61
- 90
50
votes
5 answers
Can a destructor be recursive?
Is this program well-defined, and if not, why exactly?
#include
#include
struct X {
int cnt;
X (int i) : cnt(i) {}
~X() {
std::cout << "destructor called, cnt=" << cnt << std::endl;
if ( cnt-- >…
Cubbi
- 43,318
- 13
- 94
- 159