Questions tagged [standards-compliance]
384 questions
9843
votes
29 answers
What is the "-->" operator in 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
- 483,438
- 51
- 484
- 539
373
votes
14 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
353
votes
18 answers
Can an HTML element have multiple ids?
I understand that an id must be unique within an HTML/XHTML page.
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 just curious about…

webmat
- 55,636
- 12
- 54
- 59
279
votes
7 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
- 21,672
- 4
- 22
- 19
269
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
145
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
- 68,793
- 14
- 134
- 209
142
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
- 55,205
- 59
- 188
- 364
134
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
- 345,407
- 112
- 654
- 839
131
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
- 20,925
- 9
- 72
- 110
126
votes
9 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,825
- 4
- 32
- 40
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
- 483,438
- 51
- 484
- 539
120
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,313
- 4
- 24
- 31
116
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
- 13,712
- 21
- 62
- 84
70
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,936
- 13
- 64
- 91
53
votes
3 answers
Java reflection: Is the order of class fields and methods standardized?
Using reflection on Java classes to access all field, methods, and so on:
Is there a standardized order of these elements (which is specified in some standard)?
Of course, I could check it empirically, but I need to know if it's always
the…

ivan_ivanovich_ivanoff
- 18,703
- 25
- 79
- 100